Package Exports
- duration-converter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (duration-converter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 } = require('duration-converter');
const sevenWeeks = new Duration('7 Weeks');
const milliseconds = sevenWeeks.MilliSeconds;
const threeDays = Duration.fromDays(3);
const hours = threeDays.Hours;
// will print out "4 days"
console.log(Duration.fromSeconds(345600).toString());
const a = new Date(2019, 3, 14);
const b = new Date(2019, 3, 15);
const betweenDates = Duration.between(a, b);
// will print 86400000
console.log(betweenDates.MilliSeconds);
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.