示例#1
0
 public function passDate()
 {
     if (!$this->params->publish_up && !$this->params->publish_down) {
         // no date range set
         return $this->assignment == 'include';
     }
     require_once dirname(__DIR__) . '/text.php';
     RLText::fixDate($this->params->publish_up);
     RLText::fixDate($this->params->publish_down);
     $now = $this->getNow();
     $up = $this->getDate($this->params->publish_up);
     $down = $this->getDate($this->params->publish_down);
     if (isset($this->params->recurring) && $this->params->recurring) {
         if (!(int) $this->params->publish_up || !(int) $this->params->publish_down) {
             // no date range set
             return $this->assignment == 'include';
         }
         $up = strtotime(date('Y') . $up->format('-m-d H:i:s', true));
         $down = strtotime(date('Y') . $down->format('-m-d H:i:s', true));
         // pass:
         // 1) now is between up and down
         // 2) up is later in year than down and:
         // 2a) now is after up
         // 2b) now is before down
         if ($up < $now && $down > $now || $up > $down && ($up < $now || $down > $now)) {
             return $this->assignment == 'include';
         }
         // outside date range
         return $this->pass(false);
     }
     if ((int) $this->params->publish_up && strtotime($up->format('Y-m-d H:i:s', true)) > $now || (int) $this->params->publish_down && strtotime($down->format('Y-m-d H:i:s', true)) < $now) {
         // outside date range
         return $this->pass(false);
     }
     // pass
     return $this->assignment == 'include';
 }