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)

This commit is contained in:
Kovid Goyal 2009-10-20 15:54:54 -06:00
parent dc0a4d9db3
commit a865155f07

View File

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