business\Business::within PHP Метод

within() публичный Метод

public within ( DateTime $date )
$date DateTime
    public function within(\DateTime $date)
    {
        $tmpDate = clone $date;
        $tmpDate->setTimezone($this->timezone);
        if (!$this->holidays->isHoliday($tmpDate) && null !== ($day = $this->getDay((int) $tmpDate->format('N')))) {
            return $day->isTimeWithinOpeningHours(Time::fromDate($tmpDate), $tmpDate);
        }
        return false;
    }

Usage Example

Пример #1
0
 public function testBackwardsCompatibleArrays()
 {
     $holiday = new \DateTime('2015-05-11');
     $business = new Business([new Day(Days::MONDAY, [['09:00', '13:00'], ['14:00', '17:00']]), new SpecialDay(Days::FRIDAY, function (\DateTime $date) {
         return [['10:00', '13:00'], ['14:00', '17:00']];
     })], [$holiday]);
     $this->assertFalse($business->within($holiday));
 }