Timezone fixes

master
pictuga 2020-04-10 20:33:59 +02:00
parent ee78a7875a
commit 8e5e8d24a4
2 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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])