From a865155f07befa6265851a2e048f108cd2200399 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 20 Oct 2009 15:54:54 -0600 Subject: [PATCH] Fix a bug in the new news download scheduler code that would cause scheduling based on time of day to not always work (depending on your timezone) --- src/calibre/web/feeds/recipes/collection.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/web/feeds/recipes/collection.py b/src/calibre/web/feeds/recipes/collection.py index 8002ce07bb..6529665e6b 100644 --- a/src/calibre/web/feeds/recipes/collection.py +++ b/src/calibre/web/feeds/recipes/collection.py @@ -230,15 +230,18 @@ class SchedulerConfig(object): typ, sch, ld = self.un_serialize_schedule(recipe) except: return False + utcnow = datetime.utcnow() if typ == 'interval': - return datetime.utcnow() - ld > timedelta(sch) + return utcnow - ld > timedelta(sch) elif typ == 'day/time': day, hour, minute = sch now = datetime.now() is_today = day < 0 or day > 6 or \ day == calendar.weekday(now.year, now.month, now.day) - return is_today and datetime.utcnow().date() != ld.date() and \ - now.hour >= hour and now.minute >= minute + is_time = now.hour >= hour and now.minute >= minute + was_downloaded_already_today = \ + utcnow - ld < timedelta(days=1) + return is_today and not was_downloaded_already_today and is_time return False def set_account_info(self, urn, un, pw):