millis
Convert different measures (minutes, hours, etc..) to milliseconds.
Because code is read by humans we don't like this.
const CACHE_TIMEOUT = 30 * 24 * 60 * 60 * 1000; const COOKIE_EXPIRE = Date + 1209600000;
But we do like this.
const CACHE_TIMEOUT = const COOKIE_EXPIRE = Date + 14 * ;
Install
npm install --save millis
Import
const seconds = ;const minutes = ;const hours = ;const days = ;const weeks = ;const months = ;const years = ;
ES Modules
;
Usage
const THIRTY_SECONDS = ;const SIX_HOURS = 6 * ;const TWO_DAYS_AND_TWO_HOURS = 2 * + 2 * ;
All methods are available in singular and plural.
const year = ;const ONE_YEAR = ;
In seconds
Because often timestamps are in unix format. You might need your duration in seconds instead of milliseconds.
const hours = ;const unix = ;const ONE_YEAR = 2 * * ;
Extending Number prototype
If you don't understand the implication of extending a native prototype [1] [2], don't use this.
; const TWO_DAYS = 2;const SIX_HOURS = 6;