fix timezone representation for TWINT tweets

This commit is contained in:
msk
2022-10-04 04:01:01 -07:00
parent ebd49e9c8c
commit 2fdb44cef9
3 changed files with 36 additions and 17 deletions
+5 -2
View File
@@ -1,4 +1,5 @@
import datetime
from zoneinfo import ZoneInfo
import platform
import pytz
@@ -69,9 +70,11 @@ class TalentTweet:
if quoted_id == -1:
quoted_id = util.get_user_id_online(quoted_username)
# FIXME: resultant tweets don't show timezone properly
# NOTE: strptime doesn't attach timezone info.
# tweet's datetime will be in local time
date_time = datetime.datetime.strptime(tweet.datetime, '%Y-%m-%d %H:%M:%S %Z')
print(date_time)
LOCAL_TIMEZONE = datetime.datetime.now().astimezone().tzinfo
date_time = date_time.replace(tzinfo=LOCAL_TIMEZONE) # attach system local timezone
return TalentTweet(tweet_id=tweet.id, author_id=tweet.user_id, date_time=date_time, mrq=(mentions, reply_to, quoted_id))
@staticmethod