-
Notifications
You must be signed in to change notification settings - Fork 156
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
Some cron expression will build incorrect intervals #156
Comments
@coolnk2001 thanks for reporting this! I'll look into this during the following days. |
@coolnk2001 HELP~ I have meet the same problem,do you solve it ? |
@coolnk2001 @xmabul can you provide any reference to other cron implementation that supports this behavior as described in the issue description? What I'm seeing here:
Shortly, step modifier cannot work together with non-range values. |
I see your reasoning for this. I don't know if there's a "cron standard" that dictates what is right or wrong here, but could I suggest to translate a non-range value to a ranged one when used with a step modifier. So This to work more transparently with what we have with the cron support for the python library apscheduler (never mind that they went of the rails, by having dow 0 being Monday..) |
Yeah, it sounds to be the most logical behaviour that most people expect of this. However, The other option, maybe even clearer/cleaner way to handle this, could be returning an error when an explicit range is not provided with step modifier. Technically this behaviour isn't currently supported and should yield an error. At least it gives some feedback to the user. |
Hi @harrisiirak Today I ran into the issue discussed above. I also think that yielding an error is the way to go in this case. I use cron-parser together with other packages and this is causing inconsistencies. Do you have any idea how straight-forward it is to add this? |
Hi @harrisiirak I am implementing an extra validation rule which checks each part of the cron expression against the following regex: ^\d{1,2}/\d{1,2}$ This should detect strings where specific, non-range values are used together with a step modifier, e.g. "0/5". Do you see any immediate problems with this? |
Hi @oavanruiten ! I'm using this library too and also found myself in the same requirement. I ended up using I think its a good workaround for this issue while the behavior is being defined! |
|
…fy as it'd be very difficult to make stringify work with these expressions
(An easy to reproduce test case will dramatically decrease the resolution time.)
Example
Cron format | 0 */2 * ? * * work for every 2 minute start from 0 is ok
so the schedule is 11:00, 11:02, 11:04, 11:06 ....
Cron format | 0 1/2 * ? * * work for every 2 minute start from 1 is not ok,
the expected schedule is 11:01, 11:03, 11:05, 11:07 ....
but it give 11:01, 12:01, 13:01, 14:01....
Strange that this expression is working ... 0 1-40/2 * ? * *
I use the library test directly here is the result
*/2 * * ? * *
Date: Tue Apr 23 2019 09:47:26 GMT+0800
Date: Tue Apr 23 2019 09:47:28 GMT+0800
Date: Tue Apr 23 2019 09:47:30 GMT+0800
1/2 * * ? * *
Date: Tue Apr 23 2019 09:48:01 GMT+0800
Date: Tue Apr 23 2019 09:49:01 GMT+0800
Date: Tue Apr 23 2019 09:50:01 GMT+0800
1-59/2 * * ? * *
Date: Tue Apr 23 2019 09:47:25 GMT+0800
Date: Tue Apr 23 2019 09:47:27 GMT+0800
Date: Tue Apr 23 2019 09:47:29 GMT+0800
0 */2 * ? * *
Date: Tue Apr 23 2019 09:48:00 GMT+0800
Date: Tue Apr 23 2019 09:50:00 GMT+0800
Date: Tue Apr 23 2019 09:52:00 GMT+0800
0 1/2 * ? * *
Date: Tue Apr 23 2019 10:01:00 GMT+0800
Date: Tue Apr 23 2019 11:01:00 GMT+0800
Date: Tue Apr 23 2019 12:01:00 GMT+0800
0 1-59/2 * ? * *
Date: Tue Apr 23 2019 09:49:00 GMT+0800
Date: Tue Apr 23 2019 09:51:00 GMT+0800
Date: Tue Apr 23 2019 09:53:00 GMT+0800
The text was updated successfully, but these errors were encountered: