getNext() errors
Closed this issue · 5 comments
ThomasPerraudin commented
Thank you for the v3.0.1. It works better.
But I think that I found 2 new errors.
$tests = [
[
"expression" => '0 10 * * *',
"timezone" => 'Europe/Paris',
"now" => "2022-04-11T10:00:00+02:00", //1649664000
"expected" => "2022-04-12T10:00:00+02:00" //1649750400
],
[
"expression" => '0 10 * * *',
"timezone" => 'Europe/Paris',
"now" => "2022-04-11T10:02:00+02:00", //1649664120
"expected" => "2022-04-12T10:00:00+02:00" //1649750400
],
];
foreach($tests as $test){
$expr = new CronExpression($test['expression'], new DateTimeZone($timezone));
$now = strtotime($test['now']);
$test['getNext'] = $expr->getNext($now);
$test['getNext_c'] = date('c', $test['getNext']);
$test['result'] = ($test['getNext_c']==$test['expected']?"ok":"** ERROR **");
print_r($test);
}
Output:
Array
(
[expression] => 0 10 * * *
[timezone] => Europe/Paris
[now] => 2022-04-11T10:00:00+02:00
[expected] => 2022-04-12T10:00:00+02:00
[getNext] => 1649714400
[getNext_c] => 2022-04-12T00:00:00+02:00
[result] => ** ERROR **
)
Array
(
[expression] => 0 10 * * *
[timezone] => Europe/Paris
[now] => 2022-04-11T10:02:00+02:00
[expected] => 2022-04-12T10:00:00+02:00
[getNext] => 1649714400
[getNext_c] => 2022-04-12T00:00:00+02:00
[result] => ** ERROR **
)
poliander commented
Yes, I introduced these yesterday... (sigh)
poliander commented
I noticed my mistake early in the morning when I looked at the changes I made yesterday. I fixed this one in v3.0.2 and v2.4.4 and added your cases to the unit tests.
Again, thank you very much for reporting and giving such good test cases.
ThomasPerraudin commented
Thank you !
ThomasPerraudin commented
I can confirm that it works great on our projects. Thank you for this very useful code.
poliander commented
Glad to hear that! Thank you very much for your positive feedback.