예제 #1
0
파일: DailyJob.php 프로젝트: foowie/cron
 public function run()
 {
     $record = $this->repository->find($this->name);
     $midnight = new DateTime('midnight');
     $now = new DateTime();
     $expectedTime = new DateTime($this->hour);
     if ($record->lastRun !== null && $record->lastRun >= $midnight || $now < $expectedTime) {
         return false;
     }
     $this->repository->updateTime($this->name, new DateTime());
     return $this->job->run();
 }
예제 #2
0
 public function run()
 {
     $record = $this->repository->find($this->name);
     if ($record->lastRun !== null) {
         $timeLimit = new DateTime($record->lastRun->format('Y-m-d H:i:s') . ' + ' . $this->interval);
         if ($timeLimit > new DateTime()) {
             return false;
         }
     }
     $this->repository->updateTime($this->name, new DateTime());
     return $this->job->run();
 }
예제 #3
0
파일: MidnightJob.php 프로젝트: foowie/cron
 public function run()
 {
     $record = $this->repository->find($this->name);
     if ($record->getLastRun() !== null) {
         $midnight = $this->dateTimeProvider->getTime('midnight');
         $midnightOfLastRun = $this->dateTimeProvider->getTime($record->getLastRun()->format('Y-m-d'));
         if ($midnight == $midnightOfLastRun) {
             return false;
         }
     }
     $this->repository->updateTime($this->name, new DateTime());
     return $this->job->run();
 }