diff options
author | Brendan McCollam <brendan@mccoll.am> | 2014-06-27 03:02:17 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2014-06-27 03:09:50 +0300 |
commit | 057bd4ceaa015920a633b32f4d769b11a87f52e7 (patch) | |
tree | c989f3bb04cd4235213a7eae40bd4b225118ad45 /apscheduler/job.py | |
parent | 707e9cafe83e572465be7f7572df90fc660ae451 (diff) | |
download | apscheduler-057bd4ceaa015920a633b32f4d769b11a87f52e7.tar.gz |
Handle naive datetimes passed as next_run_time
Diffstat (limited to 'apscheduler/job.py')
-rw-r--r-- | apscheduler/job.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/apscheduler/job.py b/apscheduler/job.py index bb9f86f..7c2b3a4 100644 --- a/apscheduler/job.py +++ b/apscheduler/job.py @@ -1,11 +1,11 @@ from collections import Iterable, Mapping -from datetime import datetime from uuid import uuid4 import six from apscheduler.triggers.base import BaseTrigger -from apscheduler.util import ref_to_obj, obj_to_ref, datetime_repr, repr_escape, get_callable_name, check_callable_args +from apscheduler.util import ref_to_obj, obj_to_ref, datetime_repr, repr_escape, get_callable_name, check_callable_args, \ + convert_to_datetime class Job(object): @@ -95,8 +95,8 @@ class Job(object): """ Computes the scheduled run times between ``next_run_time`` and ``now`` (inclusive). - :type now: datetime - :rtype: list[datetime] + :type now: datetime.datetime + :rtype: list[datetime.datetime] """ run_times = [] @@ -189,9 +189,7 @@ class Job(object): if 'next_run_time' in changes: value = changes.pop('next_run_time') - if value and not isinstance(value, datetime): - raise TypeError('next_run_time must be either None or a datetime instance') - approved['next_run_time'] = value + approved['next_run_time'] = convert_to_datetime(value, self._scheduler.timezone, 'next_run_time') if changes: raise AttributeError('The following are not modifiable attributes of Job: %s' % ', '.join(changes)) |