From 8e5e8d24a406af74e106f1d091f647c2f8a7da66 Mon Sep 17 00:00:00 2001 From: pictuga Date: Fri, 10 Apr 2020 20:33:59 +0200 Subject: [PATCH] Timezone fixes --- morss/feeds.py | 6 +++--- morss/morss.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index 1004d82..ef5348f 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -484,13 +484,13 @@ def parse_time(value): elif isinstance(value, basestring): if re.match(r'^[0-9]+$', value): - return datetime.fromtimestamp(int(value), tz.UTC) + return datetime.fromtimestamp(int(value), tz.tzutc()) else: - return dateutil.parser.parse(value) + return dateutil.parser.parse(value).replace(tzinfo=tz.tzutc()) elif isinstance(value, int): - return datetime.fromtimestamp(value, tz.UTC) + return datetime.fromtimestamp(value, tz.tzutc()) elif isinstance(value, datetime): return value diff --git a/morss/morss.py b/morss/morss.py index 50d339b..36df115 100644 --- a/morss/morss.py +++ b/morss/morss.py @@ -1,7 +1,10 @@ import sys import os import os.path + import time +from datetime import datetime +from dateutil import tz import threading @@ -420,7 +423,8 @@ def FeedGather(rss, url, options): t.daemon = True t.start() - sorted_items = sorted(rss.items, key=lambda x:x.updated or x.time or 0, reverse=True) + now = datetime.now(tz.tzutc()) + sorted_items = sorted(rss.items, key=lambda x:x.updated or x.time or now, reverse=True) for i, item in enumerate(sorted_items): if threads == 1: worker(*[i, item])