Python library for parsing the opening hour format used by OpenStreetMap.
Project description
opening-hours-osm
Python library for parsing the opening hour format used by OpenStreetMap.
Reference: https://wiki.openstreetmap.org/wiki/Key:opening_hours
The library was ported from this Rust library https://github.com/remi-dupre/opening-hours-rs.
Usage
from datetime import datetime
from opening_hours_osm import OpeningHours, Context, GeoLocale, CountryHolidays
ctx = Context(
# Locale for determining timezone and astronomic events
GeoLocale(48.36658170393406, 10.89542692530624),
CountryHolidays("DE", "BY")
)
oh = OpeningHours.parse("Mo-Fr 09:00-18:00; PH off", ctx)
for r in oh.iter_range(datetime(2021, 4, 8, 0, 0), datetime(2021, 4, 11, 0, 0)):
print(r.start.isoformat(), "-", r.end.isoformat(), r.kind, r.comments)
assert oh.is_open(datetime(2021, 4, 8, 12, 0))
2021-04-08T00:00:00+02:00 - 2021-04-08T09:00:00+02:00 closed []
2021-04-08T09:00:00+02:00 - 2021-04-08T18:00:00+02:00 open []
2021-04-08T18:00:00+02:00 - 2021-04-09T09:00:00+02:00 closed []
2021-04-09T09:00:00+02:00 - 2021-04-09T18:00:00+02:00 open []
2021-04-09T18:00:00+02:00 - 2021-04-11T00:00:00+02:00 closed []
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opening_hours_osm-0.1.1.tar.gz.
File metadata
- Download URL: opening_hours_osm-0.1.1.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89b0ba46f00bba9f1f352af458f56bbaaf65915887c5d8950f2ad727fa8592bd
|
|
| MD5 |
52d451c5cfbedb20f3c3c457fb486573
|
|
| BLAKE2b-256 |
d9f20238db600a5d81f8d2fb5002f05a0c9101fbb1bbb7d3a0741723d095256c
|
File details
Details for the file opening_hours_osm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: opening_hours_osm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 27.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2d7b858c83e5703fd7f16c88bac87fb5ea99dc45c69723db00353c654bbb0f5
|
|
| MD5 |
dac9ceae47bbb328546a371e784e0ddb
|
|
| BLAKE2b-256 |
d0fc1441398e65fd19cc3092e6721139ea872773a9a350de7c9c8598cdde22ca
|