legacy google takeout: fix timezone localization

This commit is contained in:
Dima Gerasimov 2024-08-03 16:43:10 +01:00 committed by karlicoss
parent d5fccf1874
commit 9e72672b4f

View file

@ -5,12 +5,14 @@ Google Takeout exports: browsing history, search/youtube/google play activity
from enum import Enum from enum import Enum
import re import re
from pathlib import Path from pathlib import Path
from datetime import datetime, timezone from datetime import datetime
from html.parser import HTMLParser from html.parser import HTMLParser
from typing import List, Optional, Any, Callable, Iterable, Tuple from typing import List, Optional, Any, Callable, Iterable, Tuple
from collections import OrderedDict from collections import OrderedDict
from urllib.parse import unquote from urllib.parse import unquote
import pytz
from ...core.time import abbr_to_timezone from ...core.time import abbr_to_timezone
@ -29,7 +31,8 @@ def parse_dt(s: str) -> datetime:
# old takeouts didn't have timezone # old takeouts didn't have timezone
# hopefully it was utc? Legacy, so no that much of an issue anymore.. # hopefully it was utc? Legacy, so no that much of an issue anymore..
# todo although maybe worth adding timezone from location provider? # todo although maybe worth adding timezone from location provider?
tz = timezone.utc # note: need to use pytz here for localize call later
tz = pytz.utc
else: else:
s, tzabbr = s.rsplit(maxsplit=1) s, tzabbr = s.rsplit(maxsplit=1)
tz = abbr_to_timezone(tzabbr) tz = abbr_to_timezone(tzabbr)