public function CronRule::getNextSchedule in Ultimate Cron 7.2
Get next schedule time of rule in UNIX timestamp format.
Return value
int UNIX timestamp of next schedule time.
File
- ./
CronRule.class.php, line 380 - This class parses cron rules and determines last execution time using least case integer comparison.
Class
- CronRule
- @file This class parses cron rules and determines last execution time using least case integer comparison.
Code
public function getNextSchedule() {
$time = $this->time;
$last_schedule = $this
->getLastSchedule();
$next_schedule = NULL;
// If the rule can't be parsed we don't proceed as this could lead to an
// infinite loop.
if (!$this
->parseRule()) {
return $next_schedule;
}
// Do a binary search for the next schedule.
$interval = 86400 * 30;
$offset = $interval;
do {
$test = new CronRule($this->rule, $time + (int) $offset, $this->skew);
$schedule = $test
->getLastSchedule();
$interval /= 2;
if ($schedule > $last_schedule) {
$next_schedule = $schedule;
$offset -= $interval;
}
elseif ($next_schedule) {
$offset += $interval;
}
else {
// Increase interval by doubling up.
// (we've already halved it, so now we quadrouple it).
$offset = $interval *= 4;
}
} while ($interval > 30);
return $next_schedule;
}