Human readable time measurements
npm install human-intervalConverts words written in English to numbers by using node-numbered.
Originally inspired by matthewmueller/date.
Human Interval is used by job scheduling libraries such as Agenda and Bree. They are a job schedulers for Node.js with cron expression syntax, human-friendly times, Dates, and more!
``js
const humanInterval = require('human-interval');
setTimeout(() => {
// Do something!
}, humanInterval('three minutes'));
`
Human Interval understands all of the following examples:
`js`
humanInterval('minute');
humanInterval('one minute');
humanInterval('1.5 minutes');
humanInterval('3 days and 4 hours');
humanInterval('3 days, 4 hours and 36 seconds');
humanInterval('4 months, 3 days, 5 hours and forty-five seconds');
Supports the following units in the plural and singular forms:
- secondsminutes
- hours
- days
- weeks
- months
- — assumes 30 daysyears
- — assumes 365 days
Supports numbers being written out in English words.
`js`
humanInterval('five minutes');
Supports hyphenated numbers.
`js`
humanInterval('twenty-five seconds');
Supports negative numbers if the time starts with a - symbol immediately followed by a number.
`js``
humanInterval('-2 minutes');