示例#1
0
 /**
  * @param Job $originalJob
  *
  * @return Job
  */
 private function getRepeatedJob(Job $originalJob)
 {
     $notBefore = null === $originalJob->getNotBefore() ? time() : $originalJob->getNotBefore()->getTimestamp();
     $delta = strtotime($originalJob->getRepeat(), $notBefore) - $notBefore;
     $now = time();
     $nextTime = $notBefore + $delta;
     while ($nextTime < $now) {
         $nextTime += $delta;
         // Crashing risk!
     }
     $nextTimeObject = new \DateTime();
     $nextTimeObject->setTimestamp($nextTime);
     if (null !== $originalJob->getExpires()) {
         $nextExpire = new \DateTime();
         // Expiring jobs
         if (null === $originalJob->getNotBefore()) {
             $nextExpire->setTimestamp($nextTime + abs($originalJob->getAdded()->getTimestamp() - $originalJob->getExpires()->getTimestamp()));
         } else {
             $nextExpire->setTimestamp($nextTime + abs($originalJob->getNotBefore()->getTimestamp() - $originalJob->getExpires()->getTimestamp()));
         }
     } else {
         $nextExpire = null;
     }
     return new Job($originalJob->getName(), $originalJob->getScript(), $originalJob->getPriority(), $nextTimeObject, $nextExpire, $originalJob->getRepeat(), $originalJob->getLink());
 }
示例#2
0
文件: Log.php 项目: pedropena/cron
 public function __construct(Job $job, $expired = false)
 {
     $this->jobId = $job->getId();
     $this->name = $job->getName();
     $this->priority = $job->getPriority();
     $this->repeat = $job->getRepeat();
     $this->due = $job->getExpires();
     $this->link = $job->getLink();
     if ($expired) {
         $this->expired = new \DateTime();
     } else {
         $this->performed = new \DateTime();
     }
 }