From c391c50ab1bd004797e5c8796a3d63e4b254023a Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 5 Nov 2020 04:15:31 +0000 Subject: [PATCH] use localize --- apiserver/feeds/news.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apiserver/feeds/news.py b/apiserver/feeds/news.py index 52f5d54..23e147a 100644 --- a/apiserver/feeds/news.py +++ b/apiserver/feeds/news.py @@ -29,14 +29,14 @@ def unix(date_str, tz=None): try: dt = datetime.strptime(date_str, f) if tz: - dt = dt.replace(tzinfo=pytz.timezone(tz)) + dt = pytz.timezone(tz).localize(dt) return int(dt.timestamp()) except: pass try: dt = datetime.strptime(date_tzfix, f) if tz: - dt = dt.replace(tzinfo=pytz.timezone(tz)) + dt = pytz.timezone(tz).localize(dt) return int(dt.timestamp()) except: pass @@ -223,4 +223,4 @@ if __name__ == '__main__': print(posts[:1]) print(site.story(posts[0])) - \ No newline at end of file +