georust / gpx

Rust read/write support for GPS Exchange Format (GPX)
https://crates.io/crates/gpx
MIT License
98 stars 44 forks source link

Time Parsing #77

Closed 0b11001111 closed 1 year ago

0b11001111 commented 2 years ago

Hello everybody,

first of all thanks for providing this great package!

I stumbled over a GPX file that contains the following time stamp <time>2021-10-10T09:55:20.952</time> which causes an Rfc3339Error during parsing. The file, however, validates against the GPX 1.1 schema

$ xmllint --schema http://www.topografix.com/GPX/1/1/gpx.xsd /tmp/test.gpx --noout
/tmp/test.gpx validates

Both, GPX 1.0 and GPX 1.1 define time stamps as xsd:dateTime which is neither RFC 3339 nor ISO 8601 by definition, although the latter strongly inspired it. See this great visualization for comparison of the standards 😎.

I suggest to assume ISO 8601 by default. Since the world isn't perfect, I also suggest to implement an fall back on RFC 3339 in error cases or, even better, allow for user defined error handlers. In my case, for instance, I don't really care about the time stamp and would pass a callback that simply ignores the "malformed" input.

If you're interested, I can start working on a PR 🙃

0b11001111 commented 2 years ago

In the linked PR I updated the code to use ISO 8601 without the fallback options among some minor fixes

lnicola commented 1 year ago

This is was fixed in #78 and is now published, thanks again @0b11001111!