Skip to main content

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

jsonify-opening-hours-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonify_opening_hours-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file jsonify-opening-hours-0.1.0.tar.gz.

File metadata

  • Download URL: jsonify-opening-hours-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for jsonify-opening-hours-0.1.0.tar.gz
Algorithm Hash digest
SHA256 21dd65ecafc6cd411e70f79ae20263a5f499497305d6f23b16b115cc0297b0c6
MD5 f5e4298b0797c10c2504a994359e35dc
BLAKE2b-256 d7a68a2698bfd20c0b30e04884f86da92f1323dddd43164e3a9ae8fd0141f15e

See more details on using hashes here.

File details

Details for the file jsonify_opening_hours-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jsonify_opening_hours-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.5

File hashes

Hashes for jsonify_opening_hours-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4513fb06c02bbd83512ed4c39e7e22571e629dff6564ab5be41bb22353442de3
MD5 d105cd0175b6ba1ccebdf2085bd97865
BLAKE2b-256 5c74bad20d8bfa2014baabad4d8f4a9624e4537e7d775cd8fe51aa9f1fbf1e95

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page