Skip to content

faustbrian/opening-hours

GitHub Workflow Status Latest Version on Packagist Software License Total Downloads


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.
  • QueryOptions controls 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.

About

An immutable opening-hours engine built around typed schedules, date-specific override rules, and schema.org adapters.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages