Skip to content

Latest commit

 

History

History
23 lines (15 loc) · 708 Bytes

File metadata and controls

23 lines (15 loc) · 708 Bytes

NPM version

This utility helps you with converting to and from time units, as well as displaying a string representation of duration.

import {Seconds} from "seconds-util";

const workWeekMs = Seconds.days(5).ms();

Seconds.y().duration().full(); // 1 year
Seconds.d(5).duration().full(); // 5 days

const date = new Date();
date.setDate(date.getDate() + 5);

Seconds.delta(date).duration().full() // In 4 days, 23 h, 59 min, 59 s, 999 ms

// Display duration up to the "days" unit.
Seconds.delta(date).duration().days() // In 5 days

// Lowercase "in" prefix, if preffered.
Seconds.delta(date).duration(false).days() // in 5 days