twitter.twint: localize timestamps correctly

same issue as discussed here https://memex.zulipchat.com/#narrow/stream/279610-data/topic/google.20takeout.20timestamps

also see corresponding changes for google_takeout_parser

- https://github.com/seanbreckenridge/google_takeout_parser/pull/28/files
- https://github.com/seanbreckenridge/google_takeout_parser/pull/30/files
This commit is contained in:
Dima Gerasimov 2022-05-30 17:24:09 +01:00 committed by karlicoss
parent de7972be05
commit d65e1b5245
2 changed files with 23 additions and 12 deletions

View file

@ -26,7 +26,7 @@ from typing import NamedTuple, Iterator, List
from pathlib import Path
from ..core.common import get_files, LazyLogger, Json, datetime_aware
from ..core.time import abbr_to_timezone
from ..core.time import localize_with_abbr
log = LazyLogger(__name__)
@ -49,9 +49,8 @@ class Tweet(NamedTuple):
def created_at(self) -> datetime_aware:
seconds = self.row['created_at'] / 1000
tz_abbr = self.row['timezone']
tz = abbr_to_timezone(tz_abbr)
dt = datetime.fromtimestamp(seconds, tz=tz)
return dt
naive = datetime.fromtimestamp(seconds)
return localize_with_abbr(naive, abbr=tz_abbr)
@property
def screen_name(self) -> str: