-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Import of track data from Gadgetbridge gets recorded in UTC time #2014
Comments
Related #301. Don't recall any details (after four years). |
Relevant code is in KmlTrackImporter. |
And here is the KML 2.3 spec: https://docs.ogc.org/is/12-007r2/12-007r2.html Happy digging ;) |
Gadgetbridge shares the track as gpx, not kml. The timestamps are formated as ISO8601, in UTC, following the gpx and xml specs. |
Then the relevant code is here: https://github.com/OpenTracksApp/OpenTracks/blob/main/src%2Fmain%2Fjava%2Fde%2Fdennisguse%2Fopentracks%2Fio%2Ffile%2Fimporter%2FGpxTrackImporter.java#L278 OpenTracks is not using the gpx.time at all - |
And gpx.time is actually the creation timestamp of the file according to: https://www.topografix.com/GPX/1/1/#element_gpx |
Is it possible that gpx.time (I assume you mean the one in metadata) not having a timezone is the reason the timezone in the initial trackpoint isn't getting read in? |
Possibly :) The XML parser code is ancient. |
So I manually edited a gpx that was importing with the wrong time and set the metadata to match the first trackpoint (with the Z), and it imports the same as without that tweak. I also noticed that the date for an imported gpx looks like |
@prurigro can you share a trimmed down GPX example and your expectation? |
Hey for sure- this isn't trimmed down, hopefully that's OK. It's a direct export from gadgetbridge, but keep in mind that I've tried editing the metadata to include the correct time + timezone and it doesn't do anything differently. All you should need to do to see the issue is gunzip it (github won't let me upload a gpx without gzipping it), then share the gpx to OpenTracks and have it import it. The activity took place on Sunday, November 3rd at 11:33am, but it will appear in the OpenTracks list showing |
Thanks. However, I don't have a computer at hand (only a phone). |
Ahh that makes sense- OK, I've trimmed it down to a single trackpoint and tested to confirm that it still has the same issue:
|
Okay... GPX 1.1 states:
IIRC OpenTracks will use the offset of the first wptType.time (similar to KML), but this should always be zero. So, a solution may be that we take the offset from metadataType.time (and ignore the actual timestamp)? |
Hmm, this is a bit more complicated than I'd initially thought. I just checked to see how osmand's exported gpx metadata looks, and it uses UTC:
So that solution wouldn't work for Osmand (and presumably others), and @joserebelo is planning on fixing the metadata time in Gadgetbridge so it complies with the standard too. Using the current local timezone doesn't necessarily make sense either because of daylight savings, or maybe you imported a track from a trip once you're back home. In theory GPS could be used to determine the timezone (and the date to see whether it should be in daylight time or not), but that seems like a solution that would require a LOT of work if there isn't already a library for it, especially with certain places observing daylight savings and other places not... It's a shame there's no standard field to add the timezone to the metadata. What if OpenTracks simply allowed editing the timezone attached to a given track? At that point you could import with UTC, or defaulting to the current local timezone might be better as it would cover most cases, and then the user could edit the ones that were incorrect? |
:) OpenTracks only considers the timezone offset as handling all the wonderful timezone details is too complicated for this case. Adding a UI to change timezone offset is doable. @prurigro do you have the time for a PR? |
The next month or so is looking pretty tight, but I can try my hand at figuring out what's going on after that if this is still open when things calm down a bit :) |
Describe the bug
Importing a recorded activity from Gadgetbridge causes OpenTracks to store it without converting the time from UTC to the local timezone. The metadata
<time></time>
in the exported gpx is incorrectly set to the export time and lacks aZ
at the end, but OpenTracks appears to use the first trkpt<time></time>
, which does have the correct UTC time with a Z at the end (eg:<time>2024-11-05T04:09:10Z</time>
).Here's the connected issue @ Gadgetbridge: https://codeberg.org/Freeyourgadget/Gadgetbridge/issues/4299
To Reproduce
Technical information
Thanks!
The text was updated successfully, but these errors were encountered: