示例#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
 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();
 }