protected function JobSchedulerCronTab::nextDay in Job Scheduler 8.2
Same name and namespace in other branches
- 8.3 src/JobSchedulerCronTab.php \Drupal\job_scheduler\JobSchedulerCronTab::nextDay()
Finds the next day from date that matches with cron parameters.
Maybe it's possible that it's within the next years, maybe no day of a year matches all conditions. However, to prevent infinite loops we restrict it to the next year.
Parameters
array $date: Date array with: 'mday', 'mon', 'year', 'hours', 'minutes'.
int $limit: (optional) The time limit in days. Defaults to 366.
Return value
array|false A date array, or false if there was an error.
1 call to JobSchedulerCronTab::nextDay()
- JobSchedulerCronTab::nextDate in src/
JobSchedulerCronTab.php - Finds the next occurrence within the next year as a date array.
File
- src/
JobSchedulerCronTab.php, line 199
Class
- JobSchedulerCronTab
- Class for job scheduler crontab.
Namespace
Drupal\job_schedulerCode
protected function nextDay(array $date, $limit = 366) {
// Safety check, we love infinite loops.
$i = 0;
while ($i++ <= $limit) {
// This should fix values out of range, like month > 12, day > 31.
// So we can trust we get the next valid day, can't we?
$time = mktime(0, 0, 0, $date['mon'], $date['mday'] + 1, $date['year']);
$date = getdate($time);
if ($this
->checkDay($date)) {
$date['hours'] = reset($this->cron['hours']);
$date['minutes'] = reset($this->cron['minutes']);
return $date;
}
}
return FALSE;
}