Skip to content

iethree/timeofday-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

turn natural language dates into something usable

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published