cline/opening-hours

A helper to query and format a set of opening hours

Maintainers

Package info

github.com/faustbrian/opening-hours

pkg:composer/cline/opening-hours

Statistics

Installs: 137

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.2 2026-03-11 03:02 UTC

This package is auto-updated.

Last update: 2026-03-15 08:34:01 UTC


README

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.