cothema/opening-hours

Opening hours component

v1.0.3 2018-03-21 09:19 UTC

This package is auto-updated.

Last update: 2024-03-29 03:09:17 UTC


README

Downloads this Month Latest stable

Installation

Install cothema/opening-hours using Composer:

$ composer require cothema/opening-hours

Example Usage

use Cothema\OpeningHours\Model\OpeningHours;
use Cothema\OpeningHours\Status;
use Nette\Utils\DateTime;

$openingHours = new OpeningHours;
$openingHours->setOpeningHours([
    '0' => ['10:00', '20:00'], // Sunday
    '1' => ['22:00', '02:00 +1 day'], // Monday
    '2' => ['08:00', '24:00'], // Tuesday
    '3' => ['08:00', '20:00'], // Wednesday
    '4' => ['10:00', '20:00'], // Thursday
    '5' => ['00:00', '20:00'], // Friday
    '6' => ['01:00', '24:00'] // Saturday
]);

$openingHours->addSpecificDay('2015-11-15', ['12:00', '16:00']);
$openingHours->addSpecificDays(['2015-11-20', '2015-11-25'], ['10:00', '01:00 +1 day']);
$openingHours->addSpecificDays(['2015-12-01', '2015-12-02'], FALSE); // Closed all the day

$status = new Status($openingHours);
$status->setTime(new DateTime('2015-11-30 12:00:00')); // Monday
$status->isOpened(); // returns FALSE