format-seconds
v0.3.1
Published
Format duration in seconds to readable string
Downloads
45
Readme
format-seconds
Format duration in seconds to readable string.
A partial implementation (104 ~ 10-24) of https://en.wikipedia.org/wiki/Orders_of_magnitude_(time)
Examples
Test cases
| input | expected | |:-------|:-----------| | 24236 | 6.73 h | | 10000 | 10000.00 s | | 1000 | 1000.00 s | | 1.244 | 1.24 s | | 0.0023 | 2.30 ms | | 0.0000023 | 2.30 µs | | 2.3e-9 | 2.30 ns | | 1 | 1.00 s |
Installation
For Node.js:
npm install format-secondsFor Browsers:
Add a script tag which points to formatSeconds.min.js
Usage
formatSeconds(0.042); // 0.042msLicense
MIT
