diff options
author | Alex Grönholm <alex.gronholm@nextday.fi> | 2014-05-31 14:34:15 +0300 |
---|---|---|
committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2014-05-31 14:34:15 +0300 |
commit | 83fa7cba9563f58794098f30b1510c96c43ea4b3 (patch) | |
tree | d3beef94ddf29903d151544ddfeca8fc6026c00c /apscheduler/triggers/cron | |
parent | 435d0ba09bdf0737f595041223ba74640786270a (diff) | |
download | apscheduler-83fa7cba9563f58794098f30b1510c96c43ea4b3.tar.gz |
Changed the trigger API to allow it to work with run times in the past
Diffstat (limited to 'apscheduler/triggers/cron')
-rw-r--r-- | apscheduler/triggers/cron/__init__.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/apscheduler/triggers/cron/__init__.py b/apscheduler/triggers/cron/__init__.py index 27362b8..c3dca9d 100644 --- a/apscheduler/triggers/cron/__init__.py +++ b/apscheduler/triggers/cron/__init__.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timedelta from tzlocal import get_localzone import six @@ -129,12 +129,14 @@ class CronTrigger(BaseTrigger): difference = datetime(**values) - dateval.replace(tzinfo=None) return self.timezone.normalize(dateval + difference) - def get_next_fire_time(self, start_date): - if self.start_date: - start_date = max(start_date, self.start_date) - next_date = datetime_ceil(start_date).astimezone(self.timezone) + def get_next_fire_time(self, previous_fire_time, now): + if previous_fire_time: + start_date = max(now, previous_fire_time + timedelta(microseconds=1)) + else: + start_date = max(now, self.start_date) if self.start_date else now fieldnum = 0 + next_date = datetime_ceil(start_date).astimezone(self.timezone) while 0 <= fieldnum < len(self.fields): field = self.fields[fieldnum] curr_value = field.get_value(next_date) |