Socket
Socket
Sign inDemoInstall

duration-converter

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    duration-converter

a small utility for converting between duration units.


Version published
Weekly downloads
472
decreased by-4.07%
Maintainers
1
Install size
17.0 kB
Created
Weekly downloads
 

Changelog

Source

1.3.6

  • Dev dependency security updates.

Readme

Source

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.

Keywords

FAQs

Last updated on 22 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc