mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
dc0a4d9db3
commit
a865155f07
@ -230,15 +230,18 @@ class SchedulerConfig(object):
|
|||||||
typ, sch, ld = self.un_serialize_schedule(recipe)
|
typ, sch, ld = self.un_serialize_schedule(recipe)
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
utcnow = datetime.utcnow()
|
||||||
if typ == 'interval':
|
if typ == 'interval':
|
||||||
return datetime.utcnow() - ld > timedelta(sch)
|
return utcnow - ld > timedelta(sch)
|
||||||
elif typ == 'day/time':
|
elif typ == 'day/time':
|
||||||
day, hour, minute = sch
|
day, hour, minute = sch
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
is_today = day < 0 or day > 6 or \
|
is_today = day < 0 or day > 6 or \
|
||||||
day == calendar.weekday(now.year, now.month, now.day)
|
day == calendar.weekday(now.year, now.month, now.day)
|
||||||
return is_today and datetime.utcnow().date() != ld.date() and \
|
is_time = now.hour >= hour and now.minute >= minute
|
||||||
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
|
return False
|
||||||
|
|
||||||
def set_account_info(self, urn, un, pw):
|
def set_account_info(self, urn, un, pw):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user