Humanized Interval
Human readable interval parser and human-readable generator for Node.js/the Browser.
Merged and wrapped rschmukler/human-interval and EvanHahn/HumanizeDuration.js into a single utility.
Heavily inspired by
matthewmueller/date.
Example Usage
var humanizedInterval = require('humanized-interval');
setTimeout(function() {
}, humanizedInterval('three minutes'));
More sophisticated examples
humanizedInterval understands all of the following examples:
humanizedInterval('one minute');
humanizedInterval('1.5 minutes');
humanizedInterval('3 days and 4 hours');
humanizedInterval('3 days, 4 hours and 36 seconds');
humanizedInterval(50000);
humanizedInterval(90000);
The full list
Supported Units
Humanized Interval supports the following units
seconds
minutes
hours
days
weeks
months
-- assumes 30 daysyears
-- assumes 365 days
Wordy Numbers
Humanized Interval supports numbers up to ten being written out in English. If you
want to extend it, you can do so by adding more keys to the language map.
Alternatively you could add support for alternative languages.
var humanizedInterval = require('humanized-interval');
humanizedInterval.languageMap['one-hundred'] = 100
humanizedInterval('one-hundred and fifty seconds')