taichino / croniter

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

Unexpected result when month is "0/{step}" #165

Closed cuu508 closed 2 years ago

cuu508 commented 3 years ago

I came across this expression: 0 1 0/10 * *. In human language, I would interpret as to "At 1:00 AM, on every 10th day-of-month, from 0 through 31".

If I generate the next matching datetimes with croniter, here's the results I get:

2021-05-10T01:00:00 2021-05-20T01:00:00 2021-05-30T01:00:00 2021-06-01T01:00:00 2021-06-10T01:00:00 2021-06-20T01:00:00 2021-06-30T01:00:00 2021-07-01T01:00:00 2021-07-10T01:00:00 2021-07-20T01:00:00

Note the timestamps in bold. Obviously, there's no 0th of June or 0th of July. Intuitively, I expected croniter to skip over them, but instead it substituted these dates with 1st of June and 1st of July.

vixie cron does not accept 0 1 0/10 * * at all, it requires day-of-month to be between 1 and 31.

My question is: is this a case of "garbage in, garbage out", or is croniter mimicking some cron implementation other than vixie?

kiorky commented 3 years ago

It's counterintuitive to have the first days in the 10th indeed. you can make a PR for it, to exclude when we have a 0/th range to exclude the first month match.

croniter uses his own implementation, mostly based on UNIX cron and not vixie.

laterly, a user contributed ranges and jenkins like styles.