Пример #1
0
 public function testCompareDate()
 {
     $d1 = new DateTime('2016-02-03 12:30');
     $d2 = new DateTime('2016-04-02 11:30');
     $d3 = new DateTime('2016-02-03 13:30');
     $this->assertEquals(-1, Dates::compareDate($d1, $d2));
     $this->assertEquals(0, Dates::compareDate($d1, $d3));
     $this->assertEquals(1, Dates::compareDate($d2, $d1));
 }
 /**
  * Checks whether this IrregularOpening is active on the given date.
  *
  * @param     DateTime  $now          The DateTime to compare against. Default is the current time.
  * @param     bool      $excludeNext  Whether to exclude the next day if timeEnd is less or equal that timeStart
  *
  * @return    bool                    Whether this IO is active on the given date
  */
 public function isActiveOnDay(DateTime $now = null, $excludeNext = false)
 {
     if ($now == null) {
         $now = Dates::getNow();
     }
     if ($excludeNext) {
         return $this->getDate()->format(Dates::STD_DATE_FORMAT) == $now->format(Dates::STD_DATE_FORMAT);
     } else {
         return Dates::compareDate($this->timeStart, $now) <= 0 and Dates::compareDate($this->timeEnd, $now) >= 0;
     }
 }