Handle astimezone() exceptions when scheduling

See http://www.mobileread.com/forums/showthread.php?t=275411
This commit is contained in:
Kovid Goyal 2016-06-22 06:32:18 +05:30
parent 2e20978300
commit 79cfd37e86

View File

@ -424,14 +424,20 @@ class SchedulerConfig(object):
return utcnow() - ld > timedelta(sch)
elif typ == 'day/time':
now = nowf()
try:
ld_local = ld.astimezone(local_tz)
except Exception:
return False
day, hour, minute = sch
return is_weekday(day, now) and \
not was_downloaded_already_today(ld_local, now) and \
is_time(now, hour, minute)
elif typ == 'days_of_week':
now = nowf()
try:
ld_local = ld.astimezone(local_tz)
except Exception:
return False
days, hour, minute = sch
have_day = False
for day in days:
@ -443,7 +449,10 @@ class SchedulerConfig(object):
is_time(now, hour, minute)
elif typ == 'days_of_month':
now = nowf()
try:
ld_local = ld.astimezone(local_tz)
except Exception:
return False
days, hour, minute = sch
have_day = now.day in days
return have_day and \