Python module providing access to the opening_hours.js library which is written in JavaScript.
This python library only implements the simple API from opening_hours.js at the moment (without optional parameters).
Install pyopening_hours simply by using pip:
pip install pyopening_hours
import pyopening_hours
try:
oh = pyopening_hours.OpeningHours('Lun-')
except pyopening_hours.ParseException as error:
print(error.message)
value = 'Mon,Tu,Th,Fr 12:00-18:00; Samstag 12:00-17:00 "I ❤ unicode"; Th[3] OFF; Th[-1] off'
oh = pyopening_hours.OpeningHours(value)
print(f"Parsing complex value: {value}")
print(f"Is{'' if oh.isWeekStable() else ' not'} week stable")
print(f"Facility is {oh.getStateString()}")
print(f"Next change in UTC: {oh.getNextChange().strftime('%Y-%m-%d %H:%M:%S')}")
print("Warnings:")
for line in oh.getWarnings():
print(' ' + line)
Just clone the repository with
git clone https://github.com/opening-hours/pyopening_hours
and install it’s dependencies (execute inside the repository):
make dependencies-get
This library is used in the following projects:
- osm-opening-hours (pure python implementation)
- Python_OpeningHours