Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current_time() is not valid in gpsbabel_testmode() #993

Open
tsteven4 opened this issue Jan 20, 2023 · 5 comments
Open

current_time() is not valid in gpsbabel_testmode() #993

tsteven4 opened this issue Jan 20, 2023 · 5 comments

Comments

@tsteven4
Copy link
Collaborator

Today, in gpsbabel_testmode(), i.e., if GPSBABEL_FREEZE_TIME is set, current_time is set to the unix epoch. current_time is of type gpsbabel::DateTime. gpsbabel::DateTime.isValid() considers the unix epoch to be invalid. This is problematic in that current_time cannot be checked for validity before use.

Some possible solutions are:

  1. change gpsbabel::DateTime.isValid() to match QDateTime::isValid(), i.e., no special handling of the unix epoch. This is problematic as historically creation_time was of type time_t, and we considered time_t=0 invalid. I think removing the assumption that the unix epoch is invalid, and relying on QDateTime::isValid is an ideal solution, although difficult to implement.
  2. change current_time in test mode to a time both gpsbabel::DateTime and QDateTime consider valid, e.g. 1980-01-06T00:00:00Z. This involves massive changes to references, but doesn't force us to remove the historical assumption about the unix epoch.
@robertlipe
Copy link
Collaborator

robertlipe commented Jan 20, 2023 via email

@tsteven4
Copy link
Collaborator Author

I would say an invalid date time in csv is an empty field. We are part way there, QDateTIme, QDate, QTime toString methods return an empty string if the object is invalid. I am not at all sure we use empty fields for this purpose in csv writers consistently.

I implemented 1). Our test cases show issues with

  • gpx reader
  • holux reader
  • humminbird reader and writer
  • igc reader
  • random realtime writer in test mode

All but the last can be fixed to work either way. The last is tied up with testmode and current_time, and if we are to consider the epoch valid then a reference file needs to change.

the gpx reader is easy to fix and a clear omission as we moved to QDateTime.

holux doesn't really seem to know if time is local or gmt, and our single sample seems to have no time information at all. The holux writer doesn't even set the timespec before converting the creation_time, although this is undetected in test. It's easy to keep the test going but I have to ask if this format is even used anymore. I can't find any reference files on the web.
holux as a company is gone, the mtk_logger seemed to generate a lot of traffic in the last few years, but maybe the holux gm-100 format is ready to die.

humminbird has comments rejecting time_t = 0 values in routes/tracks, if we do the same for waypoints we get the reader fixed. We do have a sample with a time_t value of 0 (and 1???) seemingly mixed in with other valid data. Fixing that reveals a writer issue. gpsbabel::DateTime.toTime_t returns -1 cast to a uint for and invalid object, as Qt did before, but if we are using time_t = 0 to indicate invalid in the binary file we need to handle it.

igc is actively in use, and has recent specs. Lots of samples are on the web. We can "fix" the code so the test works, although we may be chasing our tail here with reference files we created.

@robertlipe
Copy link
Collaborator

robertlipe commented Jan 21, 2023 via email

@robertlipe
Copy link
Collaborator

@tsteven4 , you said you implemented approach. Did you ever land this? Please close this if so.

@tsteven4
Copy link
Collaborator Author

This is not resolved.

qDebug() << current_time() << current_time().isValid();
in testmode this results in

QDateTime(1970-01-01 00:00:00.000 UTC Qt::UTC) false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants