@time-utils/duration

1.1.0 • Public • Published

Duration

A Class to handle durations of time. Provides convenience methods to get the duration in seconds, minutes, hours, days

Installation

npm install @time-utils/duration

Usage

import { Duration } from '@time-utils/duration';

The Class accepts a single argument, the number of milliseconds of the duration in question.

Class Methods

Duration.between takes two Date instances and returns the Duration between those Dates

Instance Methods

duration.minus accepts a Duration instance and returns a new Duration of the difference between the two.

Instance properties

Durations contain multiple properties to get the value in different units of time. Available properties are:

  • milliseconds
  • seconds
  • minutes
  • hours
  • days

Parts of the duration can by accessed using a singular form:

  • millisecond
  • second
  • minute
  • hour

As an example, 1300 milliseconds would return 300 for the millisecond part, and 1 for the second part

Package Sidebar

Install

npm i @time-utils/duration

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

3.57 kB

Total Files

5

Last publish

Collaborators

  • typhoon_2099