PHPackages                             ujamii/osm-opening-hours - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. ujamii/osm-opening-hours

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

ujamii/osm-opening-hours
========================

Parser for Openstreetmap opening hours format

v2.0.1(5mo ago)911.7k↓15%3[3 PRs](https://github.com/ujamii/osm-opening-hours/pulls)1MITPHPPHP &gt;=8.2CI passing

Since Dec 6Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ujamii/osm-opening-hours)[ Packagist](https://packagist.org/packages/ujamii/osm-opening-hours)[ RSS](/packages/ujamii-osm-opening-hours/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (13)Used By (1)

Openstreetmap opening hours parser in PHP
=========================================

[](#openstreetmap-opening-hours-parser-in-php)

[![Packagist](https://camo.githubusercontent.com/7cba33dffcdc193527962de989701c68cb2db18c99989911a72e90936f029a7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f756a616d69692f6f736d2d6f70656e696e672d686f7572732e7376673f636f6c6f72423d677265656e267374796c653d666c6174)](https://packagist.org/packages/ujamii/osm-opening-hours)[![Minimum PHP Version](https://camo.githubusercontent.com/82e1f15c26fe5ddabeb60f2d3bbb501d018b7731685d23b8e9c7792dada5095e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d3838393242462e7376673f7374796c653d666c6174)](https://php.net/)[![Continuous Integration](https://github.com/ujamii/osm-opening-hours/actions/workflows/php.yml/badge.svg)](https://github.com/ujamii/osm-opening-hours/actions)

Parser for the [Openstreetmap opening hours format](https://wiki.openstreetmap.org/wiki/Key:opening_hours) as connector for the library [`spatie/opening-hours`](https://github.com/spatie/opening-hours).

Installation
------------

[](#installation)

`composer require ujamii/osm-opening-hours`

Usage
-----

[](#usage)

```
$hours = OsmStringToOpeningHoursConverter::openingHoursFromOsmString('Mo-Sa 10:00-18:00');
$hours->isOpenAt(new \DateTimeImmutable('2022-01-10 16:00:00')); // true, this is a monday
$hours->isOpenAt(new \DateTimeImmutable('2022-03-06 16:00:00')); // false, as this is a sunday
```

There are a lot more methods on the `$hours` object, please check the [docs](https://github.com/spatie/opening-hours#usage) of that library. Of course, you can also use some more complex input like (please also check the [docs](https://wiki.openstreetmap.org/wiki/Key:opening_hours)) and the list of missing features below to see what's actually possible:

```
Mo-Fr 08:00-12:00,13:00-17:30; Sa 08:00-12:00
Sa 08:00-12:00; Mo 11:30-17:00; Tu 11:30-18:00; Dec 23-31 off; Jan 24 off; Oct 10 off; PH off; Apr 16 off

```

If you also need to support the public holiday feature (like `PH off` in the example above), you have to pass in a filter like this:

```
$hours = OsmStringToOpeningHoursConverter::openingHoursFromOsmString('Mo-Su 10:00-18:00; PH 09:00-12:00', ['PH' => new GermanPublicHolidayFilter()]);
$hours->isOpenAt(new \DateTimeImmutable('2022-01-10 16:00:00')); // true, open late on normal day
$hours->isOpenAt(new \DateTimeImmutable('2022-01-01 16:00:00')); // false, closed late on holiday
$hours->isOpenAt(new \DateTimeImmutable('2022-01-01 11:00:00')); // true, open early on holiday
```

The filter for German holidays is [included already](src/Filters/GermanPublicHolidayFilter.php), so please take at look at this and the [corresponding interface](src/Filters/Filter.php), if you want to implement something specific for you. The expected config array may look like `['PH' => new GermanPublicHolidayFilter()]` where the key `PH` has to match the beginning of the ruleset in the given OSM string and the value is an instance of your filter class. Input values like `PH 09:00-12:00` or `PH off` will be parsed and given to the filter in the `setOpeningHours` method. The `spatie/opening-hours`library will call the `applyFilter(\DateTimeImmutable $date)` method internally when something like `isOpenAt` is requested.

Running tests
-------------

[](#running-tests)

You can run the tests with `composer run phpunit` or `composer run testall` for test and static analysis.

License and Contribution
------------------------

[](#license-and-contribution)

[MIT](LICENSE)

As this is OpenSource, you are very welcome to contribute by reporting bugs, improve the code, write tests or whatever you are able to do to improve the project. Just fork and PR.

If you want to do me a favour, buy me something from my [Amazon wishlist](https://www.amazon.de/registry/wishlist/2C7LSRMLEAD4F).

Known issues / missing features
-------------------------------

[](#known-issues--missing-features)

- the `spatie/opening-hours` library does not support different settings for a weekday based on the week (like `week 01-53/2 Fr 09:00-12:00; week 02-52/2 Fr 14:00-18:00`), so we have to add this information via the data attribute which the library supports for each given opening hour value (this may be solved by another filter)
- constraint features like years, year\_range, year, months, monthdays and week\_range are not or not completely supported. This may also be solved by the filter feature later
- things like `week 14-24` and `week 1,3,7,34` are not supported yet
- the OSM input string is not validated yet
- No support for constrained weekdays yet `Th[1,2-3], Fr[-1]`
- No support for calculations yet `Sa[-1],Sa[-1] +1 day`

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance75

Regular maintenance activity

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~118 days

Total

4

Last Release

173d ago

Major Versions

v1.0.1 → v2.0.02025-04-15

PHP version history (2 changes)v1.0.0PHP &gt;=8.0

v2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1526725?v=4)[Michael Grundkötter](/maintainers/mgrundkoetter)[@mgrundkoetter](https://github.com/mgrundkoetter)

---

Top Contributors

[![mgrundkoetter](https://avatars.githubusercontent.com/u/1526725?v=4)](https://github.com/mgrundkoetter "mgrundkoetter (93 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (56 commits)")[![arnaudcogifor](https://avatars.githubusercontent.com/u/208596666?v=4)](https://github.com/arnaudcogifor "arnaudcogifor (1 commits)")[![FrancescuCOGIFOR](https://avatars.githubusercontent.com/u/188875749?v=4)](https://github.com/FrancescuCOGIFOR "FrancescuCOGIFOR (1 commits)")

---

Tags

opening-hoursopeninghoursopenstreetmapopenstreetmap-dataosm

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ujamii-osm-opening-hours/health.svg)

```
[![Health](https://phpackages.com/badges/ujamii-osm-opening-hours/health.svg)](https://phpackages.com/packages/ujamii-osm-opening-hours)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
