cline / opening-hours
A helper to query and format a set of opening hours
2.0.2
2026-03-11 03:02 UTC
Requires
- php: ^8.5.0
Requires (Dev)
- cline/coding-standard: ^1.5.6
- orchestra/testbench: ^10.8
- symfony/var-dumper: ^7.4.0
README
opening-hours
An immutable opening-hours engine built around typed schedules, date-specific override rules, and schema.org adapters.
Requirements
Requires PHP 8.5+
Installation
composer require cline/opening-hours
Usage
use Cline\OpeningHours\OpeningHours; use Cline\OpeningHours\QueryOptions; $openingHours = OpeningHours::fromArray([ 'monday' => ['09:00-17:00'], 'tuesday' => ['09:00-17:00'], 'exceptions' => [ '2026-12-24' => [], '2026-12-31 to 2027-01-02' => ['10:00-14:00'], '01-01' => [], ], ], new QueryOptions( timezone: 'Europe/Helsinki', )); $openingHours->isOpenAt(new DateTimeImmutable('2026-03-09 10:00:00')); $openingHours->nextOpen(new DateTimeImmutable('2026-03-09 18:00:00')); $openingHours->asStructuredData();
V2 API
OpeningHours::fromArray()builds schedules from weekday definitions plus explicit exception rules.OpeningHours::fromWeeklySchedule()builds directly from typed value objects.OpeningHours::createFromStructuredData()imports schema.org opening hour specifications.QueryOptionscontrols input timezone, output timezone, and search limits for transition queries.
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
Credits
License
The MIT License. Please see License File for more information.