Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dlevs/time

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dlevs/time

A class for simple conversion between units of time.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Time

Time is a JavaScript class for converting time between units. All operations are immutable and return new Time instances instead of modifying the current instance.

Installation

npm install @dlevs/time

Overview

import Time from '@dlevs/time';

const time = new Time({ days: 1 });

// Getters
time.toMilliseconds();  // 86400000
time.toSeconds();       // 86400
time.toMinutes();       // 1440
time.toHours();         // 24
time.toDays();          // 1
time.toComponents();    // { days: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }

// Operators
time.add({ hours: 12 }).toDays();     // 1.5
time.subtract({ days: 2 }).toDays();  // -1
time.multiply(2).toDays();            // 2
time.divide(2).toDays();              // 0.5

Documentation

View the API documentation for more details and example usage.

FAQs

Package last updated on 17 Jul 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc