Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/599316527/duration-time
parse / format duration time
https://github.com/599316527/duration-time
duration formatting
Last synced: 3 months ago
JSON representation
parse / format duration time
- Host: GitHub
- URL: https://github.com/599316527/duration-time
- Owner: 599316527
- License: mit
- Created: 2016-03-31T07:10:19.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-01T08:50:11.000Z (almost 9 years ago)
- Last Synced: 2024-10-11T04:33:57.876Z (3 months ago)
- Topics: duration, formatting
- Language: JavaScript
- Size: 13.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Duration Time
====================================## Usage
```JavaScript
const DurationTime = require('duration-time')// Format a duration time into h:m:s
DurationTime().format(11111) === '03:05:11'// Specify colon number
DurationTime({
colonNumber: 1
}).format(11111) === '185:11'// Without leading zeros
DurationTime({
hasLeadingZero: false
}).format(11111) === '3:5:11'// Always display decimals
DurationTime({
alwaysDisplayDecimals: true
}).format(11111) === '03:05:11.00'// Specify decimals width
DurationTime({
keepDecimals: 2
}).format(11111.1) === '185:11.10'// Pasre formatted string back
DurationTime.parse('03:05:11.10') === 11111.1
DurationTime.parse('185:11') === 11111
```