Closed lowtower closed 3 years ago
@lowtower
Can you add this line in file timezone_adjuster.py
for test? and try again.
I am thinking some gpx we can not get tz_name info.
time.replace(tzinfo=timezone.utc)
also need to add import line
from datetime import timezone
from datetime import timezone
class TimezoneAdjuster:
_timezonefinder: typing.Optional[timezonefinder.TimezoneFinder] = None
def __init__(self) -> None:
if not TimezoneAdjuster._timezonefinder:
TimezoneAdjuster._timezonefinder = timezonefinder.TimezoneFinder()
@classmethod
def adjust(cls, time: datetime.datetime, latlng: s2sphere.LatLng) -> datetime.datetime:
# If a timezone is set, there's nothing to do.
if time.utcoffset():
return time
assert cls._timezonefinder
tz_name = cls._timezonefinder.timezone_at(lat=latlng.lat().degrees, lng=latlng.lng().degrees)
if tz_name is None:
time.replace(tzinfo=timezone.utc)
return time
tz = pytz.timezone(tz_name)
tz_time = time.astimezone(tz)
return tz_time
Thanks for Your quick reply!
The modification did work! I get some errors for only a few gpx files such as:
Error while loading ~/2020/activity_5702364393.gpx: Track has no start or end time.
I have to have a closer look at these files.
Thanks a lot, cheers, LT
Thanks for Your quick reply!
The modification did work! I get some errors for only a few gpx files such as:
Error while loading ~/2020/activity_5702364393.gpx: Track has no start or end time.
I have to have a closer look at these files.
Thanks a lot, cheers, LT
@lowtower
Maybe this gpx has something wrong, you can open it to see if it contains info or not.
You can delete the activity_5702364393.gpx file from the folder to see what happens.
If you have other gpx files like this, maybe you need to delete them too.
@flopp @lowtower
I think I can take a pr
to fix this issue later~
I checked the relevant gpx files - they were not "running" files but "cardio" without time info - so the error messages are reasonable.
Thanks for Your help and filing the pr!
I try to generate a poster with some gpx files extracted from my garmin account. I have downloaded the files using the proposed python script garmin-connect-export. Now, I get the following error:
Is something wrong with my gpx files? As said, they all come from the same source.
Thanks in advance, LT.