duration-time-format
Advanced tools
Comparing version
{ | ||
"name": "duration-time-format", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Duration Time Format/Parse", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Duration Time | ||
==================================== | ||
## Usage | ||
@@ -8,8 +9,29 @@ ```JavaScript | ||
DurationTime.format(11111) === '03:05:11' | ||
DurationTime.format(11111, 2) === '185:11' | ||
// Format a duration time into h:m:s | ||
DurationTime().format(11111) === '03:05:11' | ||
DurationTime.parse('03:05:11') === 11111 | ||
// Specify colon number | ||
DurationTime({ | ||
colonNumber: 2 | ||
}).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 | ||
``` | ||
@@ -40,5 +40,6 @@ const durationTime = require('../../index') | ||
expect(durationTime({keepDecimals: 2}).format(111)).toBe('00:01:51') | ||
expect(durationTime({keepDecimals: 2, alwaysDisplayDecimals: true}) | ||
.format(111)).toBe('00:01:51.00') | ||
expect(durationTime({keepDecimals: 2}).format(111.11)).toBe('00:01:51.11') | ||
expect(durationTime({alwaysDisplayDecimals: true}).format(111)).toBe('00:01:51.00') | ||
expect(durationTime({keepDecimals: 1}).format(111.11)).toBe('00:01:51.1') | ||
expect(durationTime().format(111.11)).toBe('00:01:51.11') | ||
expect(durationTime({keepDecimals: 2}).format(111.10)).toBe('00:01:51.10') | ||
expect(durationTime({keepDecimals: 0}).format(111.11)).toBe('00:01:51') | ||
@@ -45,0 +46,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11339
5.12%263
0.38%37
146.67%0
-100%