-
Notifications
You must be signed in to change notification settings - Fork 224
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
Weird behavior between Python 3 and Python 2.7 for timestamps #83
Comments
Up ? |
Yes, I'm here but unfortunately I don't have the time to investigate. In this specific case I'm not 100% sure what you mean "got duplicate timestamps". It would help a lot if you could provide me a code which fails (along with the gpx file). Ideally, it would be a test in |
I'll do that |
I'm not sure if this is the same issue, because I've not tested in Python 3, but I am seeing milliseconds truncated to seconds. The reason may be because my GPX file starts with no (null) milliseconds value. Here are the first two timestamps of my file. The first one has only seconds, the second has 200 milliseconds.
My guess at the cause is the I think the issue is due to the DATE_FORMATS lookup, which may be only checked once per GPX file. In gpxpy/gpxpy/gpxfield.py, the function parse_time() is called in the TimeConverter() class and contains a call to mod_gpx.DATE_FORMATS, which loops over potential datetime formats. I suspect that the first matching format is returned, which in my case is a timestamp without milliseconds. From gpx.py
From gpxfield.py (parse_field function)
Here's a sample code, using the pastebin GPX file linked above
prints the second timestamp without milliseconds
I'm using Python 2.7.12 (64 bit) and gpxpy==1.1.2 |
Yes, you're right @philshem The problem is that we can never be sure which format are the timestamps. But, again, if we implement the fix from #92 then we can:
|
One more thing, as I said, I'm pretty busy for any complex changes in gpxpy at the moment. But I think this one should be less than an hour of work (including tests). I think I could find some time this or next weekend. (of course, I'm accepting pull requests if somebody needs this sooner). |
Reversing the order is something I can do, but I guess you are referring to the DATE_FORMAT ;) But as for the function for DATE_FORMAT, I'm more than happy to wait. At the moment I use a local dev version of gpxpy, but it's really custom and not good for a patch. Many thanks! |
Hello,
When parsing a GPX where precision is on milliseconds, using Python 2 and gpxpy, no issue to get the correct timestamp value per point. But if I use Python, I end up with a 1s precision and then got duplicate timestamps when recording is less than every seconds and fail to calculate speed compared to previous point.
Are you aware of any issue with Python version and timestamp ?
Regards
In attachement the GPX I use to test.
Move_2017_02_07_12_21_36_Course.gpx.zip
The text was updated successfully, but these errors were encountered: