diff options
author | Daniel Schadt <kingdread@gmx.de> | 2022-07-16 22:30:47 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2022-07-16 22:30:47 +0200 |
commit | a07ca7c0b7e567f2647d13f84db6aed201cde56c (patch) | |
tree | fa9891caa74745d7a4e69e955f97851e30991629 | |
parent | 42cb1aff20b310c934be31491061c51e81dde35c (diff) | |
download | fietsboek-a07ca7c0b7e567f2647d13f84db6aed201cde56c.tar.gz fietsboek-a07ca7c0b7e567f2647d13f84db6aed201cde56c.tar.bz2 fietsboek-a07ca7c0b7e567f2647d13f84db6aed201cde56c.zip |
remove MyTourbook timezone guessing
It turns out that the mt:TourStartTime is also given in UTC, and
therefore cannot be used to get the timezone offset. The problem was
that my local computer's timezone was the same as the tour timezone, so
by the magic of Python's datetime.datetime.fromtimestamp (and the date
CLI util), I did not notice that the timestamp actually represents UTC.
Sadly, it currently looks like there is no way to extract the time zone
from a MyTourbook export.
-rw-r--r-- | fietsboek/util.py | 10 | ||||
-rw-r--r-- | tests/unit/test_util.py | 1 |
2 files changed, 0 insertions, 11 deletions
diff --git a/fietsboek/util.py b/fietsboek/util.py index 32b56e3..1014c87 100644 --- a/fietsboek/util.py +++ b/fietsboek/util.py @@ -125,16 +125,6 @@ def guess_gpx_timezone(gpx): offset = round_timedelta_to_multiple(offset, datetime.timedelta(minutes=15)) return datetime.timezone(offset) - # Special case for MyTourbook exports, which have a 'mt:TourStartTime' extension - if gpx.time: - for extension in gpx.metadata_extensions: - if extension.tag.lower() == '{net.tourbook/1}tourstarttime': - local_time = datetime.datetime.fromtimestamp(int(extension.text) // 1000) - time = gpx.time.astimezone(datetime.timezone.utc).replace(tzinfo=None) - offset = local_time - time - offset = round_timedelta_to_multiple(offset, datetime.timedelta(minutes=15)) - return datetime.timezone(offset) - # If all else fails, we assume that we are UTC+00:00 return datetime.timezone.utc diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index 8f45611..e63bd01 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -57,7 +57,6 @@ def test_round_timedelta_to_multiple(delta, multiple, expected): @pytest.mark.parametrize('gpx_file, offset', [ ("Teasi_1.gpx.gz", timedelta(hours=2)), - ("MyTourbook_1.gpx.gz", timedelta(hours=2)), ]) def test_guess_gpx_timezone(gpx_file, offset): asset_dir = Path(__file__).parent.parent / 'assets' |