You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
DST transitions cause APScheduler to incorrectly calculate next trigger times.
Given:
a cron trigger of month='', day='', day_of_week='0-4', hour='0', minute='0',
a last trigger time of None
a current time of pd.Timestamp(2021, 3, 12, 0, 0,0,1,0,pytz.timezone('US/Central'))
APScheduler returns '2021-03-16T00:00:00-05:00' for the cron_trigger's get_next_fire_time() call.
NOTE: there is a DST transition CST -> CDT at 2AM on 14 March.
from apscheduler.triggers.cron import CronTrigger
import pytz
import pandas as pd
cron_trigger = CronTrigger.from_crontab('0 0 * * 0-4', pytz.timezone('US/Central'))
now = pd.Timestamp(2021, 3, 12, 0, 0,0,1,0,pytz.timezone('US/Central'))
print(cron_trigger.get_next_fire_time(None,now).isoformat())
Expected behavior
To return '2021-03-15T00:00:00-05:00' not '2021-03-16T00:00:00-05:00'
Additional context
The APScheduler library determines the next fire time by going through each part of the expression and finding the next viable value iteratively until all parts of the expression are satisfied. When the day is incremented, 24 hours are added. This causes the time to go forward 1 day and 1 hour as DST causes a day to only contain 23 hours.
It seems that the _increment_field_value function needs to be corrected to accommodate DST changes NOTE: the same behavior doesn't happen on CDT->CST transitions
The text was updated successfully, but these errors were encountered:
Description
DST transitions cause APScheduler to incorrectly calculate next trigger times.
Given:
a cron trigger of month='', day='', day_of_week='0-4', hour='0', minute='0',
a last trigger time of None
a current time of pd.Timestamp(2021, 3, 12, 0, 0,0,1,0,pytz.timezone('US/Central'))
APScheduler returns '2021-03-16T00:00:00-05:00' for the cron_trigger's get_next_fire_time() call.
NOTE: there is a DST transition CST -> CDT at 2AM on 14 March.
Expected behavior
To return '2021-03-15T00:00:00-05:00' not '2021-03-16T00:00:00-05:00'
Additional context
The APScheduler library determines the next fire time by going through each part of the expression and finding the next viable value iteratively until all parts of the expression are satisfied. When the day is incremented, 24 hours are added. This causes the time to go forward 1 day and 1 hour as DST causes a day to only contain 23 hours.
It seems that the _increment_field_value function needs to be corrected to accommodate DST changes
NOTE: the same behavior doesn't happen on CDT->CST transitions
The text was updated successfully, but these errors were encountered: