Parses opening hours from various human-readable strings into a standard JSON format
Project description
Python Opening Hours parser
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": "5: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'},
{'day': 'thursday', 'opens': '9:00', 'closes': '17:30'},
{'day': 'friday', 'opens': '9:00', 'closes': '17:30'}
]
This has been tested using Python 3.8.5
Tests
run python3 -m unittest
Project details
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
Close
Hashes for jsonify-opening-hours-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21dd65ecafc6cd411e70f79ae20263a5f499497305d6f23b16b115cc0297b0c6 |
|
MD5 | f5e4298b0797c10c2504a994359e35dc |
|
BLAKE2b-256 | d7a68a2698bfd20c0b30e04884f86da92f1323dddd43164e3a9ae8fd0141f15e |
Close
Hashes for jsonify_opening_hours-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4513fb06c02bbd83512ed4c39e7e22571e629dff6564ab5be41bb22353442de3 |
|
MD5 | d105cd0175b6ba1ccebdf2085bd97865 |
|
BLAKE2b-256 | 5c74bad20d8bfa2014baabad4d8f4a9624e4537e7d775cd8fe51aa9f1fbf1e95 |