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(7mo ago)914.5k↓23.8%3[3 PRs](https://github.com/ujamii/osm-opening-hours/pulls)1MITPHPPHP &gt;=8.2CI passing

Since Dec 6Pushed 3w 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 2d ago

READMEChangelogDependencies (5)Versions (18)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

52

—

FairBetter than 96% of packages

Maintenance82

Actively maintained with recent releases

Popularity34

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

219d 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

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M47](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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