You are here

protected function JobSchedulerCronTab::nextHour in Job Scheduler 7.2

Find the next available hour within the same day.

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

File

./JobSchedulerCronTab.inc, line 172
JobSchedulerCronTab class.

Class

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

Code

protected function nextHour($date) {
  $cron = $this->cron;
  while ($cron['hours']) {
    $hour = array_shift($cron['hours']);

    // Current hour; next minute.
    if ($date['hours'] == $hour) {
      foreach ($cron['minutes'] as $minute) {
        if ($date['minutes'] < $minute) {
          $date['hours'] = $hour;
          $date['minutes'] = $minute;
          return $date;
        }
      }
    }
    elseif ($date['hours'] < $hour) {
      $date['hours'] = $hour;
      $date['minutes'] = reset($cron['minutes']);
      return $date;
    }
  }
  return FALSE;
}