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

Support for ? in Day of Week and Day of Month #76

Closed
dnafication opened this issue May 19, 2020 · 3 comments
Closed

Support for ? in Day of Week and Day of Month #76

dnafication opened this issue May 19, 2020 · 3 comments

Comments

@dnafication
Copy link

dnafication commented May 19, 2020

As per the documentation of class DayOfWeekField and DayOfMonthField, it allows ? but it looks like there is no code to support the character. Due to this, following cron expression results in exception.

$cron = Cron\CronExpression::factory('0 12 * * ? *');
$cron = Cron\CronExpression::factory('0 12 ? * * *');

Error Stacktrace

Fatal error: Uncaught InvalidArgumentException: Invalid CRON field value ? at position 4 in /Users/user/aws-cron-expression/src/Cron/CronExpression.php:162
Stack trace:
#0 /Users/user/aws-cron-expression/src/Cron/CronExpression.php(143): Cron\CronExpression->setPart(4, '?')
#1 /Users/user/aws-cron-expression/src/Cron/CronExpression.php(121): Cron\CronExpression->setExpression('0 12 * * ? ')
#2 /Users/user/aws-cron-expression/src/Cron/CronExpression.php(89): Cron\CronExpression->__construct('0 12 * * ? ', Object(Cron\FieldFactory))
#3 /Users/user/aws-cron-expression/index.php(8): Cron\CronExpression::factory('0 12 * * ? ')
#4 {main}

Do you plan to implement this?

@dnafication dnafication changed the title Support for ? in Day of week and Day of month Support for ? in Day of Week and Day of Month May 19, 2020
@NicoHaase
Copy link

Out of curiosity: I'm not that familiar with the meaning of the questionmark here, and I could not find a good example about when this makes a difference to the asterisk. By providing some test cases, you could help to implement this

@dnafication
Copy link
Author

Some examples here:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions
https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents-expressions.html

The ? (question mark) wildcard specifies one or another. In the Day-of-month field you could enter 7 and if you didn't care what day of the week the 7th was, you could enter ? in the Day-of-week field.

@dragonmantank
Copy link
Owner

The logic for if a value is valid or not is a bit dumb (there are basically two checks), and we supported ? in one check but not the other.

This is fixed in 2d923cd and will go out shortly in a bugfix release.

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