Open WUST-mengqinyu opened 3 months ago
I would claim both might be broken. */2 maps to 1-31/2 which means all old days. The day of week means Wednesday. so do you OR the resulting sets or AND the resulting sets or do you ignore one of the resulting sets. The GURU case is ignoring the day of the month and chose to use the day of the week only.
I would have said robfig ignored the day of the week, but I do not know where the 8-28 came from since I do not know which crontab specification was used.
Using https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html specification,
The opensgroup specification state it should be an OR, So guru is definitely broken and robfig is correct since 8-28 is an actual wednesday for the date range being shown.
There is a reason why the ? operator exists.
I would claim both might be broken. */2 maps to 1-31/2 which means all old days. The day of week means Wednesday. so do you OR the resulting sets or AND the resulting sets or do you ignore one of the resulting sets. The GURU case is ignoring the day of the month and chose to use the day of the week only.
I would have said robfig ignored the day of the week, but I do not know where the 8-28 came from since I do not know which crontab specification was used.
Using https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html specification,
The opensgroup specification state it should be an OR, So guru is definitely broken and robfig is correct since 8-28 is an actual wednesday for the date range being shown.
There is a reason why the ? operator exists.
If so, I think this lib should return a error rather than a not correct result?
I would agree with you if we knew which specification this repo code was written to. Since I did find a specification supporting this cron's implementation, there is no error in this repo. There is a very strong possibility that the guru repo has the error and should be generating an error.
Expr:
0 0 */2 * 3
in https://crontab.guru/ expected:at 2024-08-21 00:00:00 then at 2024-08-28 00:00:00 then at 2024-09-04 00:00:00 then at 2024-09-11 00:00:00 then at 2024-09-18 00:00:00
for this lib
res:
next 0 : 2024-08-17 00:00:00 +0800 CST next 1 : 2024-08-19 00:00:00 +0800 CST next 2 : 2024-08-21 00:00:00 +0800 CST next 3 : 2024-08-23 00:00:00 +0800 CST next 4 : 2024-08-25 00:00:00 +0800 CST next 5 : 2024-08-27 00:00:00 +0800 CST next 6 : 2024-08-28 00:00:00 +0800 CST next 7 : 2024-08-29 00:00:00 +0800 CST next 8 : 2024-08-31 00:00:00 +0800 CST next 9 : 2024-09-01 00:00:00 +0800 CST