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