An open API service indexing awesome lists of open source software.

https://github.com/boertel/duration

TypeScript library to format durations (days, hours, minutes and seconds)
https://github.com/boertel/duration

library

Last synced: 6 months ago
JSON representation

TypeScript library to format durations (days, hours, minutes and seconds)

Awesome Lists containing this project

README

          

# duration

TypeScript library to format durations (days, hours, minutes, seconds, and milliseconds)

## Install

```
npm install @boertel/duration
```

## Usage

```javascript
import { duration } from "@boertel/duration";

console.log(duration(2892992000).format("d DD, h HH [and] m MM"));
// 33 days, 11 hours and 36 minutes

// more readable way to create a duration:
const d = duration().days(2).hours(5).seconds(4);
// this will ignore 0 values and join with commas and "and"
console.log(d.format(["dD", "hH", "mM", "sS"]));
// 2d, 5h and 4s
```