From 13628001fa4603acce1525acf3a0d8cb367aa232 Mon Sep 17 00:00:00 2001 From: Kyle Mahan Date: Fri, 13 Nov 2015 22:56:59 +0000 Subject: [PATCH] strip timezone before comparing 'published' with 'now' --- woodwind/tasks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/woodwind/tasks.py b/woodwind/tasks.py index 7cd8ba6..5f47a7a 100644 --- a/woodwind/tasks.py +++ b/woodwind/tasks.py @@ -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: