Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_next and get_prev` return wrong time across DST boundary when schedule is for a specific time. #116

Closed
liammeck opened this issue Nov 4, 2018 · 1 comment

Comments

@liammeck
Copy link

liammeck commented Nov 4, 2018

I saw someone else commenting on the same problem here: #90
This seems to be a separate issue so I created this, but sorry if you consider it a duplicate.

Here's a simple example showing the problem. Schedule is 8 am on weekdays; US DST ends Nov. 4 at 2 am.

>>> foo
datetime.datetime(2018, 11, 4, 5, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
>>> cr = croniter.croniter('0 8 * * 1,2,3,4,5', foo)
>>> cr.get_prev(datetime)
datetime.datetime(2018, 11, 2, 9, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
>>> cr.get_prev(datetime)
datetime.datetime(2018, 11, 2, 8, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
>>> cr.get_prev(datetime)
datetime.datetime(2018, 11, 1, 8, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
>>> cr.get_next(datetime)
datetime.datetime(2018, 11, 2, 8, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
>>> cr.get_next(datetime)
datetime.datetime(2018, 11, 5, 7, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
>>> cr.get_prev(datetime)
datetime.datetime(2018, 11, 2, 9, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)

Notice it gives 9:00 instead of 8:00, then when we go forward across the DST boundary again it gives 7:00.

A couple more examples:

>>> foo
datetime.datetime(2018, 11, 4, 0, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
>>> cr = croniter('0 8 * * *', foo)
>>> cr.get_next(datetime)
datetime.datetime(2018, 11, 4, 7, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
>>> foo
datetime.datetime(2018, 11, 4, 7, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
>>> cr = croniter('0 8 * * *', foo)
>>> cr.get_prev(datetime)
datetime.datetime(2018, 11, 3, 9, 0, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)
@liammeck liammeck changed the title get_next returns wrong time across DST boundary. get_prev returns wrong time across DST boundary. Nov 4, 2018
@liammeck liammeck changed the title get_prev returns wrong time across DST boundary. get_next and get_prev` return wrong time across DST boundary. Nov 5, 2018
@liammeck liammeck changed the title get_next and get_prev` return wrong time across DST boundary. get_next and get_prev` return wrong time across DST boundary when minure or hour is specified in the schedule. Nov 5, 2018
@liammeck liammeck changed the title get_next and get_prev` return wrong time across DST boundary when minure or hour is specified in the schedule. get_next and get_prev` return wrong time across DST boundary when schedule is for a specific time. Nov 5, 2018
@kiorky
Copy link
Collaborator

kiorky commented Apr 10, 2020

dup #90

@kiorky kiorky closed this as completed Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants