本文整理匯總了PHP中Cron\CronExpression::getPreviousRunDate方法的典型用法代碼示例。如果您正苦於以下問題:PHP CronExpression::getPreviousRunDate方法的具體用法?PHP CronExpression::getPreviousRunDate怎麽用?PHP CronExpression::getPreviousRunDate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cron\CronExpression
的用法示例。
在下文中一共展示了CronExpression::getPreviousRunDate方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isActive
/**
* {@inheritDoc}
*/
public function isActive()
{
if (!$this->isScheduled()) {
return false;
}
$currentTime = new \DateTime();
$limitTime = $this->cronExpression->getPreviousRunDate('now', 0, true);
$limitTime->add(new \DateInterval($this->interval));
return $currentTime <= $limitTime;
}
示例2: isDue
/**
* Check if the job is due to run
*
* @return bool
*/
public function isDue()
{
if ($this->lastExecutionFile && is_readable($this->lastExecutionFile)) {
$lastExecution = file_get_contents($this->lastExecutionFile);
$lastRunDate = $this->execution->getPreviousRunDate('now', 0, true);
$nextRunDate = $this->execution->getNextRunDate();
echo (is_string($this->command) ? $this->command : '[function]') . ': ' . $lastExecution . ' | ' . $lastRunDate->getTimestamp() . ' | ' . $nextRunDate->getTimestamp() . "\n";
return $lastRunDate->getTimestamp() > $lastExecution && $this->truthTest === true;
}
return $this->execution->isDue() && $this->truthTest === true;
}
示例3: isActive
/**
* {@inheritdoc}
*/
public function isActive()
{
$now = new \DateTime('now', $this->getTimeZone());
try {
$limitDate = $this->expression->getPreviousRunDate($now, 0, true);
$limitDate->add($this->interval);
// @codeCoverageIgnoreStart
} catch (\RuntimeException $exception) {
return false;
}
// @codeCoverageIgnoreEnd
return $now <= $limitDate;
}
示例4: getPreviousRunDate
/**
* @param string $currentTime
* @param int $nth
* @param bool|false $allowCurrentDate
* @return Carbon
*/
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
{
return Carbon::instance(parent::getPreviousRunDate($currentTime, $nth, $allowCurrentDate));
}