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

> Why does get_next() return a real day for the incorrect cron expression? (1 jan for '0 0 0 0 0') #6

Closed
mikhail-kashirskii opened this issue Dec 3, 2021 · 5 comments

Comments

@mikhail-kashirskii
Copy link

But the question is - why does get_next() return a real day for the incorrect cron expression? (1 jan for '0 0 0 0 0')

This is not what the OP saidf in the first place, the OP said in the first place that is_valid returns True which is legit.

Originally posted by @kiorky in #5 (comment)

@mikhail-kashirskii mikhail-kashirskii changed the title > Wwhy does get_next() return a real day for the incorrect cron expression? (1 jan for '0 0 0 0 0') > Why does get_next() return a real day for the incorrect cron expression? (1 jan for '0 0 0 0 0') Dec 3, 2021
@kiorky
Copy link
Owner

kiorky commented Dec 3, 2021

expected and historic behavior or croniter: https://github.com/kiorky/croniter/blob/master/src/croniter/croniter.py#L108

day=0 and month=0 are aliased and expanded to day=1 month=1

@kiorky kiorky closed this as completed Dec 3, 2021
@kiorky
Copy link
Owner

kiorky commented Dec 3, 2021

( this was at the time of the write to support most UNIX expressions formats in the wild, see https://en.wikipedia.org/wiki/Cron)

@mikhail-kashirskii
Copy link
Author

Sorry, I don't see any format that takes 0 as month. Could you please point to that explicitly?
Or its just an undocumented croniter feature, right?

kiorky added a commit that referenced this issue Dec 3, 2021
@kiorky
Copy link
Owner

kiorky commented Dec 3, 2021

it's not for months but to support seconds repeat where in this case, fields are then shifted up to 6 and the 4th field becomes the day one.

As this case is pretty straightforward, i added some rule to check in in the new released croniter==1.1.0

Believe me, cron corner cases are infinite and using misformed crontabs expression will still always give you opportunity for bad ranges.

@mikhail-kashirskii
Copy link
Author

Thanks a lot!

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