Closed jerv13 closed 13 years ago
According to Cron, 0 and 7 are Sunday but the DateTime->format('N') returns an integer between 1 and 7. So, in order to be compatible with cron's expressions, you have to :
Michael, I can provide you the patch which correct and test this.
Thanks for the bug report, jerv.
Good catch, tucksaun. Providing a patch would be really helpful! I played around with it for a minute, and it looks like intervals will be more difficult than a 5 minute change.
I want to come up with more accurate test cases so that we can catch these types of issues. Anyone know a good implementation of cron that can be used to calculate the next run date of a cron expression?
-Michael
Here it is: https://gist.github.com/ad486f026738f1fc534b
Indeed the intervals were more difficult, but I think they are ok (for now). I play with this code all afternoon and it seems ok.
By the way, thank you for this code ;)
Tugdual
That looks great, tucksaun. Can you send a pull request?
done ;)
Thanks for the patch!
I think there my be a bug when both the Day of the Week and the Day of the Month are specified (See results below)
cron: * * * * * ---------------------------------------------- (OK) Next Due: 2011-06-15 23:09:00
cron: 0 17 * * * ---------------------------------------------- (OK) Next Due: 2011-06-16 17:00:00
cron: 0 0 1 1 0 ----------------------------------------------(Should be 2012-01-01 00:00:00) Next Due: 2249-10-01 00:00:00
cron: 0 0 1 * 0 ----------------------------------------------(Should be 2012-01-01 00:00:00) Next Due: 2038-10-31 00:00:00
cron: 59 17 5 7 * ----------------------------------------------(OK) Next Due: 2011-07-05 17:59:00
cron: 00 11 15 6 * ----------------------------------------------(OK) Next Due: 2012-06-15 11:00:00
cron: 00 11 14 6 * ----------------------------------------------()OK Next Due: 2012-06-14 11:00:00
I will look into this and see if I can find a solution.