duration
A small utility for converting between duration units. E.g '7 Weeks' to Micro Seconds.
Installation
Node.js
$ npm install duration-converter
Example usage:
const Duration = ; const sevenWeeks = '7 Weeks';const milliseconds = sevenWeeksMilliSeconds; const threeDays = Duration;const hours = threeDaysHours; // will print out "4 days"console; const a = 2019 3 14;const b = 2019 3 15;const betweenDates = Duration; // will print 86400000console;
Warning!
Note that a year is always interpreted as being 365 days. There are no leap year calculations so going between units that cross the year "boundaries" will result in a small rounding error.