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

Errors when Day of the Week and Day of the Month set #1

Closed
jerv13 opened this issue Jun 16, 2011 · 6 comments
Closed

Errors when Day of the Week and Day of the Month set #1

jerv13 opened this issue Jun 16, 2011 · 6 comments
Assignees

Comments

@jerv13
Copy link

jerv13 commented Jun 16, 2011

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.

@ghost ghost assigned mtdowling Jun 21, 2011
@tucksaun
Copy link
Contributor

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 :

  • use format w
  • change every 7 to 0
  • and eventually manage intervals correctly (ex: 4-7).

Michael, I can provide you the patch which correct and test this.

@mtdowling
Copy link
Owner

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

@tucksaun
Copy link
Contributor

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

@mtdowling
Copy link
Owner

That looks great, tucksaun. Can you send a pull request?

@tucksaun
Copy link
Contributor

done ;)

mtdowling added a commit that referenced this issue Jun 29, 2011
@mtdowling
Copy link
Owner

Thanks for the patch!

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

3 participants