once might already be a datetime object

This commit is contained in:
Pedro Algarvio 2018-02-26 14:02:38 +00:00
parent 88c0420fc2
commit b27bbc258c
No known key found for this signature in database
GPG Key ID: BB36BF6584A298FF

View File

@ -949,16 +949,17 @@ class Schedule(object):
not data['_splay']:
continue
if not data['_next_fire_time'] and \
not data['_splay']:
once_fmt = data.get('once_fmt', '%Y-%m-%dT%H:%M:%S')
try:
once = datetime.datetime.strptime(data['once'],
once_fmt)
except (TypeError, ValueError):
log.error('Date string could not be parsed: %s, %s',
data['once'], once_fmt)
continue
if not data['_next_fire_time'] and not data['_splay']:
once = data['once']
if not isinstance(once, datetime.datetime):
once_fmt = data.get('once_fmt', '%Y-%m-%dT%H:%M:%S')
try:
once = datetime.datetime.strptime(data['once'],
once_fmt)
except (TypeError, ValueError):
log.error('Date string could not be parsed: %s, %s',
data['once'], once_fmt)
continue
# If _next_fire_time is less than now or greater
# than now, continue.
if once < now - loop_interval: