strip timezone before comparing 'published' with 'now'

This commit is contained in:
Kyle Mahan 2015-11-13 22:56:59 +00:00
parent 0b354acaeb
commit 13628001fa

View file

@ -455,6 +455,11 @@ def hentry_to_entry(hentry, feed, backfill, now):
published = hentry.get('published')
updated = hentry.get('updated')
# make sure published timezone aware
if published and hasattr(published, 'tzinfo') and published.tzinfo:
published = published.astimezone(datetime.timezone.utc)\
.replace(tzinfo=None)
# retrieved time is now unless we're backfilling old posts
retrieved = now
if backfill and published and published < retrieved: