1.2.0 • Published 8 years ago
timelabel v1.2.0
timelabel
Convert time lengths (intervals) into a nice formatted string.
Installation
$ npm install timelabel
Test:
$ npm test
Usage/API
timelabel(number, detail)
The function takes a number as its only required argument, assuming the number is a millisecond length and converts longer lengths it to a nicer format. If the detail
argument is set to true then it will return more detail. See examples below.
Examples:
var timelabel = require('timelabel')
// milliseconds
timelabel(150) // '150 milliseconds'
// seconds
timelabel(2400) // '2 seconds'
// minutes
timelabel(200000) // '3 minutes'
timelabel(200000, true) // '3m 20s'
// hours
timelabel(38000000) // '11 hours'
timelabel(38000000, true) // '10h 33m'
// days
timelabel(3810000000) // '44 days'
timelabel(3810000000, true) // '44d 2h'
License
MIT