mtdowling / cron-expression

CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
http://mtdowling.com/blog/2012/06/03/cron-expressions-in-php/
MIT License
4.9k stars 335 forks source link

MON#1,MON#3 doesn't validate #70

Closed tqmz closed 9 years ago

tqmz commented 9 years ago

In v1.0.3 it was possible to assign multiple days of week to an DayOfWeekField expression with a week of month:

 $this->assertTrue($f->validate('MON#1,MON#3'));

In master, this doesn't validate anymore while it seems to be supported in terms of isDue().

PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'Invalid CRON field value MON#1,MON#3 as position 4' in /home/t/dev/fs/radiorecorder/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php:123
Stack trace:
#0 /home/t/dev/fs/radiorecorder/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(105): Cron\CronExpression->setPart(4, 'MON#1,MON#3')
#1 /home/t/dev/fs/radiorecorder/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(84): Cron\CronExpression->setExpression('00 14 * * MON#1...')
#2 /home/t/dev/fs/radiorecorder/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php(72): Cron\CronExpression->__construct('00 14 * * MON#1...', Object(Cron\FieldFactory))
#3 /home/t/dev/fs/radiorecorder/record.php(167): Cron\CronExpression::factory('00 14 * * MON#1...')
#4 /home/t/dev/fs/radiorecorder/record.php(45): Radiorecorder\Radiorecorder->parseBroadcasts('/home/t/dev/fs/...')
#5 /home/t/dev/fs/radiorecorder/record.php(382): Radiorecorder\Radiorecorder->__construct()
#6 {main}
  th in /home/t/dev/fs/radiorecorder/vendor/mtdowling/cron-expression/src/Cron/CronExpression.php on line 123

Is that just a matter of fixing the regex in DayOfWeekField::validate(), or for some reason an undesired expression?