gpxpy
gpxpy copied to clipboard
Parsing timezone-unaware GPX files
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!
Yes, I agree with you here. And this should be fixed together with #190 .