A python library to convert arbitrary strings representing business opening hours into a JSON format
Python Opening Hours parser
a python library to convert arbitrary strings representing business opening hours into a JSON format that’s easier to use in code
This library parses opening hours from various human-readable strings such as “Mon- Fri 9:00am – 5:30pm” into a more standard JSON format that can be processed more easily.
The format
opening_hours = [
{
"day": "monday",
"opens": "9:00",
"closes": "17:00"
},
//..
]
Installation
pip install jsonify-opening-hours
Usage
The simplest example is just printing the JSON for an opening hours string:
from parse_opening_hours import JsonOpeningHours
print(JsonOpeningHours.parse("Mon- Fri 9:00am - 5:30pm"))
This should give you the below output:
[
{'day': 'monday', 'opens': '9:00', 'closes': '17:30'},
{'day': 'tuesday', 'opens': '9:00', 'closes': '17:30'},
{'day': 'wednesday', 'opens': '9:00', 'closes': '17:30'},