Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soulman-is-good/duration-formatter
Node.js library that helps to format duration to and from human readable format
https://github.com/soulman-is-good/duration-formatter
Last synced: about 1 month ago
JSON representation
Node.js library that helps to format duration to and from human readable format
- Host: GitHub
- URL: https://github.com/soulman-is-good/duration-formatter
- Owner: soulman-is-good
- License: apache-2.0
- Created: 2022-12-09T15:52:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-02T16:22:28.000Z (10 months ago)
- Last Synced: 2024-10-12T10:12:08.267Z (2 months ago)
- Language: TypeScript
- Size: 306 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Duration formatter and parser
This library helps to format duration to and from human readable format.
## How to use
In NodeJS
```ts
import { parseDuration, formatMs } from "duration-formatter";parseDuration("2hours 30 minutes, 20 sec 453ms") === 9020453;
formatMs(1296575243) === "2 weeks 1 day 9 minutes 35 seconds 243 milliseconds";
```In the browser - not yet supported
## More libraries like this one
- Also duration formatter and parser, but for "hh:mm:ss" format from @cloudtion: https://www.npmjs.com/package/duration-formatter
- If you need just to format duration from milliseconds in "hh:mm:ss" format (@ungoldman): https://www.npmjs.com/package/format-duration
- Nice library to format milliseconds to human readable format, no parse though and only for esm (@sindresorhus): https://www.npmjs.com/package/pretty-ms
- Duration formatter and parser as this library but esm and having lodash dependency (@nicolas-van): https://www.npmjs.com/package/simple-duration
- Above one forked from this lib by @Raul-Tech-Support, but still with lodash dependency: https://www.npmjs.com/package/simple-duration-converter