timeofday-parser

1.1.5 • Public • Published

timeofday-parser

This is a simple script to parse a string containing a time of day into a known format. It accepts every reasonable english language time format I could think of.

NPM Version Linux Build

Install

npm install timeofday-parser

Usage

 
var timeParser = require('timeofday-parser');
 
output = timeParser.parse("906pm");
// {h: 21, m: 6}
 
output = timeParser.parse("26pm");
// false
 

Examples

9        {"h":9,"m":0}
9am      {"h":9,"m":0}
9p       {"h":21,"m":0}
926      {"h":9,"m":26}
0926     {"h":9,"m":26}
2126     {"h":21,"m":26}
9:26pm   {"h":21,"m":26}
9.26 am  {"h":9,"m":26}
9.26 pm  {"h":21,"m":26}
926pm    {"h":21,"m":26}
0926am   {"h":9,"m":26}
926p     {"h":21,"m":26}
9,26     {"h":9,"m":26}
9260     false
26:90    false
26pm     false

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i timeofday-parser

Weekly Downloads

2

Version

1.1.5

License

MIT

Unpacked Size

6.45 kB

Total Files

6

Last publish

Collaborators

  • iethree