gethuman / hrsoo

Lexer/parser and formatter for hours of operation
MIT License
9 stars 2 forks source link

hrsoo

This is a little utility to help parse hours of operation strings.

Overview

A string that contains the hours of operation for a business can come in many different forms. For example:

This library is an attempt to normalize any of these typical variations and output either a standard JSON data structure that contains all the hours or a specific format.

Usage - Command Line

From the command line enter:

npm install hrsoo -g
hrsoo -i "Monday through Friday 9 a.m. to 5 p.m."

Usage - Node

From the command line enter:

npm install hrsoo --save

Then in your Node.js code use the library like this:

var hrsoo = require('hrsoo');
var formatted = hrsoo.format('Monday through Friday 9 a.m. to 5 p.m.');

Usage - Browser

Include dist/hrsoo.min.js in your client build and reference it in a script tag on your page. Then simply:

var formatted = hrsoo.format('Monday through Friday 9 a.m. to 5 p.m.');

Limitations / Issues

A couple of things I am still working on: