expiry-js
A lightweight Javascript Universal Module for parsing durations.
I developed it as a utility for managing Redis expiries.
Installation
npm install expiry-js
bower install expiry-js
Usage
var
expiry = require('expiry-js');
var
example = expiry('1Y1M2W3D5h8m11s19ms'),
year = expiry('1Y'),
month = expiry('1M'),
week = expiry('1W'),
day = expiry('1D'),
hour = expiry('1h'),
minute = expiry('1m'),
second = expiry('1s'),
milliseconds = expiry('1ms'),
altMilliseconds = expiry('1', 'ms');
console.log(day.valueOf());
console.log(day.asMilliseconds());
console.log(day.asSeconds());
Change Log
0.1.7 (2015-06-20)
- Adds parsing of digits only strings. Thanks, @BigFunger
0.1.6 (2015-06-18)