You are here

public static function UltimateCronCrontabScheduler::shouldRun in Ultimate Cron 7.2

Check crontab rules against times.

1 call to UltimateCronCrontabScheduler::shouldRun()
UltimateCronRulesUnitTestCase::runTest in tests/rules.test

File

plugins/ultimate_cron/scheduler/crontab.class.php, line 123
Crontab cron job scheduler for Ultimate Cron.

Class

UltimateCronCrontabScheduler
Crontab scheduler.

Code

public static function shouldRun($rules, $job_last_ran, $time = NULL, $catch_up = 0, $skew = 0) {
  $time = is_null($time) ? time() : $time;
  foreach ($rules as $rule) {
    $cron = CronRule::factory($rule, $time, $skew);
    $cron_last_ran = $cron
      ->getLastSchedule();
    if ($job_last_ran < $cron_last_ran && $cron_last_ran <= $time) {
      if ($time <= $cron_last_ran + $catch_up) {
        return $time - $job_last_ran;
      }
    }
  }
  return FALSE;
}