Comments (7)
Hi Kai
Yes, I know the datetime parsing issues. I can add a list possible datetime formats and a 'strict' flag when parsing. If strict is False, only the strict GPX datetime format will be used (the one ending with Z) otherwise any of the list of available formats (you can then add yours if needed).
What do you think?
Regards,
tk
from gpxpy.
GPX (1.1 at least) seems to specify dateTime as the format which can include the Z, but it doesn't seem to be required. I'd say that you should parse the dateTime with the Z, without the Z, and with the offset from UTC (+/- HH:MM) formats.
Anything other than those and I'd say you should pass in a callback function to handle any non-standard string to datetime conversions.
from gpxpy.
I like both ideas.
My problem was, that i downloaded my gpx-files from my http://www.sports-tracker.com/ account and these tracks seems to have invalid timestamps: "2013-07-06T14:29:46.52" --> No Z or offset
This problem would be fixed by both of your solutions.
I like the solution with the whitelist of dateformats. That would bring up an easy way to expand the supported date formats, even if they are not valid... You should decide if you would like to support incorrect gpx-files or not.
bj1s idea is also satisfying and probably more straight forward.
from gpxpy.
bj1 & Kai, you're both! right.
I was speaking from memory but my memory is obviously faulty :) The 'T' must be there, Z isn't important. (BTW, gpxpy still don't work for gpx 1.1, it is on my "to do" list, but lack of free time... ):
The valid/strict timestamp formats are here: http://books.xmlschemata.org/relaxng/ch19-77049.html
Is anybody willing to make a list of strict formats function and (maybe) some common-but-unstrict, change parse_time(), add few unit tests and make a pull request? Otherwise, I'll do it, but probably not until the end of this month.
from gpxpy.
Here's my first try:
Note that two use cases are not yet handled:
- negative years (i suppose this isn't a big problem, ancient Greeks and Romans had a rather poor GPS devices ;)
- UTC offsets (because %z for UTC offset don't work with strptime, and even if it worked it works for +0100 not +01:00)
If you want to try, use the timestamp-fix branch.
from gpxpy.
As you said in an earlier post, the 'T' must be in the timestamp, but it
looks like the unit tests are testing version without the 'T' and are
considering them to have passed.
It all depends on how strict you want to be with the standard.
from gpxpy.
Right, I decided to accept timestamps without the T for this first try. I'll probably keep it this way. Anyway, if users try to get the GPS back with get_xml() they will get the right timestamp format.
from gpxpy.
Related Issues (20)
- Bug: `free variable 'from_start_to_end' referenced before assignment in enclosing scope` HOT 1
- Suggestion: Add project to Code Shelter to get help with project maintenance
- Allow user to enforce Haversine distance
- malformed xml HOT 4
- Proposing a PR to fix a few small typos HOT 2
- Remove waypoint while in loop? HOT 1
- Publish a pure Python wheel to PyPI? HOT 1
- Route issues HOT 7
- Incremental distance / length?
- Cannot parse files where the default namespace is http://www.garmin.com/xmlschemas/TrackPointExtension/v2 HOT 2
- Python GPXPy speed data is missing HOT 3
- coordinate bounding box HOT 2
- metadata error in bounds HOT 1
- Force stdlib etree instead of lxml? HOT 1
- Uphill Downhill are not accurate HOT 2
- GPX parsing not working with extension HOT 2
- NameError: free variable 'from_start_to_end' referenced before assignment in enclosing scope HOT 1
- Setup.py method is being deprecated in python package
- Confusion!
- Wrong distance? 10.4 km instead of 7.6 km HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpxpy.