npm

Need private packages and team management tools?Check out npm Orgs. »

duration-converter

1.3.6 • Public • Published

duration

Build Status Coverage Status npm dependencies Status devDependencies Status Downloads/week

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.

install

npm i duration-converter

Downloadsweekly downloads

389

version

1.3.6

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability