je vais jeter un oeil.
en attendant, je me suis dépatouillé autrement :
$myCron = '30 19 11 08 3 2021';
$now = date("Y-m-d H:i:s");
$cron = new cron();
$cron->setSchedule($myCron);
$c = new Cron\CronExpression(checkAndFixCron($cron->getSchedule()), new Cron\FieldFactory);
$nextRunCron = $c->getNextRunDate($now, 0, true);
$cronArray = explode(' ', $myCron); // fixed date = 6 ; real cron = 5
// if fixed date
if (count($cronArray) == 6) {
// if date asked (from $myCron) and next one calculated have the same year, then it's a real next date
if ($nextRunCron->format("Y") == $startCronArray[5]) {
return $nextRunCron->format("Y-m-d H:i:s");
}
// if not the same, then it's a calculated date in the futur => we can t apply it
else {
// calculate the previous date
$c = new Cron\CronExpression(checkAndFixCron($cron->getSchedule()), new Cron\FieldFactory);
$prevRunCron = $c->getPrevRunDate($now, 0, true);
return $prevRunCron->format("Y-m-d H:i:s");
}
}
// real cron expression
else {
return $nextRunCron->format("Y-m-d H:i:s");
}
ca semble convenir !
sauf si vous voyez un truc bizarre …?