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

Parsing timezone-unaware GPX files #182

Open
juseg opened this issue Oct 7, 2019 · 1 comment
Open

Parsing timezone-unaware GPX files #182

juseg opened this issue Oct 7, 2019 · 1 comment
Assignees

Comments

@juseg
Copy link

juseg commented Oct 7, 2019

Maybe a design question rather than a bug. Even when timezone info is missing from an input GPX file, gpxpy returns timezone-aware datetimes. Not only this may result in wrong timezones but also (luckily) timezone-aware times are typically incompatible with timezone-unaware times. For instance in Python's datetime module:

>>> import datetime
>>> utc = datetime.timezone.utc
>>> datetime.datetime(2019, 1, 2, tzinfo=utc) - datetime.datetime(2019, 1, 1)
TypeError: can't subtract offset-naive and offset-aware datetimes

Or in the latest version of pandas (v0.25.0):

>>> import pandas as pd
>>> pd.to_datetime('20190102-00:00:00+00:00') - pd.to_datetime('20190101-00:00:00')
TypeError: Timestamp subtraction must have the same timezones or no timezones

Wouldn't it be more logical that gpxpy returns timezone-unaware data when timezone information is missing? PS. Thanks a lot for your work!

@tkrajina tkrajina self-assigned this Jan 8, 2020
@tkrajina
Copy link
Owner

tkrajina commented Jan 8, 2020

Yes, I agree with you here. And this should be fixed together with #190 .

ekspla added a commit to ekspla/gpxpy that referenced this issue Mar 23, 2021
Issue tkrajina#182
Support for TZ unaware timestamps.
Issue tkrajina#190
Support for cloned GPX (using deepcopy).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants