You are here

protected function JobSchedulerCronTab::nextDay in Job Scheduler 7.2

Find 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.

1 call to JobSchedulerCronTab::nextDay()
JobSchedulerCronTab::nextDate in ./JobSchedulerCronTab.inc
Find the next occurrence within the next year as a date array,.

File

./JobSchedulerCronTab.inc, line 153
JobSchedulerCronTab class.

Class

JobSchedulerCronTab
Jose's cron tab parser = Better try only simple crontab strings.

Code

protected function nextDay($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;
    }
  }
}