Skip to main content

Parses opening hours from various human-readable strings into a standard JSON format

Project description

Python Opening Hours parser

CircleCI codecov Downloads

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'},
	{'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 and Coverage

run pytet and generate coverage database pipenv run pytest --cov=./

show coverage report: pipenv run coverage report

Build and Release

This is pretty much here so I can copy-paste the commands to make a new release.

build: python setup.py sdist bdist_wheel check: twine check dist/* upload: twine upload dist/*

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.2.0.tar.gz (7.5 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.2.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jsonify-opening-hours-0.2.0.tar.gz
  • Upload date:
  • Size: 7.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 77e7a78846beebf6b0874fe16ad8eeb40c14044f17b9006347d008ad57ab9449
MD5 5811100983bcf562a1fa05b7f2d32888
BLAKE2b-256 e6d5f0c595043796baa3fb8a439456287db2d7f0f9a2ad0de266e1b4e6b33213

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jsonify_opening_hours-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 187c784876c74600ff811ef8b4fd5e4669b53a26cc3b6a7a05cdfb163641fcc6
MD5 128c5ff4f684d0cd6b8a625821a65e90
BLAKE2b-256 870b7f7a3ba59a5fca2d307c04e73b56115c9a5c97c12e5b8ee293139a11a8c5

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