taichino / croniter

croniter is a python module to provide iteration for datetime object.
http://github.com/taichino/croniter
387 stars 105 forks source link

"0 0 */5 * *" skips over a date #166

Closed cuu508 closed 3 years ago

cuu508 commented 3 years ago

I ran the following snippet:

from datetime import datetime
from croniter import croniter

start = datetime(2022, 2, 20)

print("now: ", start.isoformat())
it = croniter("0 0 */5 * *", start)
for x in range(0, 10):
    print(it.get_next(datetime).isoformat())

And got the following results:

now:  2022-02-20T00:00:00
2022-02-21T00:00:00
2022-02-26T00:00:00
2022-03-06T00:00:00
2022-03-11T00:00:00
2022-03-16T00:00:00
2022-03-21T00:00:00
2022-03-26T00:00:00
2022-03-31T00:00:00
2022-04-01T00:00:00
2022-04-06T00:00:00

Notice that 2022-03-01 is missing from the output. I think this a bug.

I tested the same expression in Debian cron. I used the following line in crontab:

0 0 */5 * * logger -t wat every five midnights days runs

And it produced the following results:

# journalctl --since "30 days ago" -t wat | grep five
Feb 21 00:00:02 debian wat[1175]: every five midnights days runs
Feb 26 00:00:01 debian wat[4556]: every five midnights days runs
Mar 01 00:00:01 debian wat[6514]: every five midnights days runs
Mar 06 00:00:02 debian wat[9894]: every five midnights days runs
kiorky commented 3 years ago

its because of DST bugs, but i have no time to finish #148 :(.

kiorky commented 3 years ago

dup #137