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

remove timezone part from date string #77

Merged
merged 4 commits into from
Dec 16, 2016
Merged

Conversation

sjol
Copy link
Contributor

@sjol sjol commented Dec 1, 2016

passed unit tests on python2.7 (I don't have 3 currently installed)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 84.745% when pulling 1035014 on sjol:date_parse_fix into beb884f on tkrajina:master.

1 similar comment
@coveralls
Copy link

coveralls commented Dec 1, 2016

Coverage Status

Coverage decreased (-0.04%) to 84.745% when pulling 1035014 on sjol:date_parse_fix into beb884f on tkrajina:master.

@coveralls
Copy link

coveralls commented Dec 1, 2016

Coverage Status

Coverage decreased (-0.04%) to 84.745% when pulling 162fafd on sjol:date_parse_fix into beb884f on tkrajina:master.

@tkrajina
Copy link
Owner

tkrajina commented Dec 1, 2016

Yes, that makes sense, thanks!

There are just a few changes I'd add here. First, what if instead of 2014-02-02T10:03:18Z the date string in the GPX is 2014-2-2T10:3:18Z (without leading zeros in two-digit numbers). In that case your [0:18] index will not work as expected.

And, another thing, add a test in test.py. Something like:

    def test_remove_timezone_from_timestamp(self):
        xml = '<?xml version="1.0" encoding="UTF-8"?>\n'
        xml += '<gpx>\n'
        xml += '<trk>\n'
        xml += '<trkseg>\n'
        xml += '<trkpt lat="35.794159" lon="-5.832745"><time>2014-02-02T10:23:18Z-TIMEZONE_ARTIFACT_HERE</time></trkpt>\n'
        xml += '</trkseg></trk></gpx>\n'
        gpx = mod_gpxpy.parse(xml, parser=self.get_parser_type())
        self.assertEquals(gpx.tracks[0].segments[0].points[0].time, ...)

@sjol
Copy link
Contributor Author

sjol commented Dec 1, 2016

Cool, I'll take a look at adding the test as well.

Not sure if checking for digits without leading zeros, as this is not correct according to https://www.w3.org/TR/xmlschema-2/#isoformats, which I think is what GPX is based.

If we do want support it, I think only a regex could help us, but that might be a bit slow.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 84.853% when pulling 91465c1 on sjol:date_parse_fix into beb884f on tkrajina:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 84.853% when pulling 91465c1 on sjol:date_parse_fix into beb884f on tkrajina:master.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 84.853% when pulling 75fbf58 on sjol:date_parse_fix into beb884f on tkrajina:master.

@sjol
Copy link
Contributor Author

sjol commented Dec 5, 2016

This should be ready for merging now. Don't know if the regular expression affects performance a lot, but at least it should only be invoked when the time string is shorter than the expected length of 19.

With this PR it works for the gpx files produced by the very useful gps tracking app LD-log.

@tkrajina tkrajina merged commit 5ea43e5 into tkrajina:master Dec 16, 2016
@tkrajina
Copy link
Owner

Merged, thanks!

@sjol sjol deleted the date_parse_fix branch December 16, 2016 18:50
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

Successfully merging this pull request may close these issues.

3 participants