kaka2507 / cron-validator

unix cron implementation in Python
MIT License
25 stars 9 forks source link

Month matching in cron expression #6

Closed nigreon closed 3 years ago

nigreon commented 3 years ago

Hi,

I want to use the month field in cron expression but it seems there is a problem with it.

I make multiple test with get_execution_time. January month match with 1 and so one like we can see in most cron implementation. But I can build a expression with 12 (like 0 11 1 12 *) in the fourth field. There is a regex in regexes.py that limit this field from 0 to 11.

The solution for me is to correct the regex in month_re for matching "12" too. Perhaps max_value_map needs to be changed too.

Did I not understand how to build the expressions or is it a bug?

wyleung commented 3 years ago

Hi @nigreon and @vcoder4c ,

We are experiencing the same. 12 as month should be a valid month for cron (https://crontab.guru/#*_*_*_*/12_*)

We have this added to our fork https://github.com/askanna-io/cron-validator and the PR to fix this is here: https://github.com/vcoder4c/cron-validator/pull/7

kaka2507 commented 3 years ago

Thanks @nigreon and @wyleung for report and create PR to fix this issue. I am looking into this issue.

kaka2507 commented 3 years ago

Have already applied #7 and released on v1.0.3