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)
- Host: GitHub
- URL: https://github.com/boertel/duration
- Owner: boertel
- Created: 2021-11-10T15:30:52.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T16:40:19.000Z (over 1 year ago)
- Last Synced: 2025-09-27T15:09:26.304Z (9 months ago)
- Topics: library
- Language: TypeScript
- Homepage: https://github.com/boertel/duration
- Size: 233 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
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
```