Easily format the time from node.js
process.hrtime. Works with timescales ranging from weeks to nanoseconds.
Install with npm
$ npm i pretty-time --save
var pretty = ;var start = process;var time = process;console;//=> 3μs
By default, when no time increment is given as the second argument, the closest timescale is used (e.g. most granular without being less than zero).
;//=> '2w';//=> '1w';//=> '5d';//=> '20h';//=> '4h';//=> '1h';//=> '3m';//=> '21s';//=> '795ms';//=> '428μs';//=> '88ns';//=> '18ns'
(All of the following examples use
[6740, 795428088] as the hrtime array.)
This value is passed as the second argument and determines how granular to make the time.
;//=> '2h';//=> '1h 52m';//=> '1h 52m 21s'
Valid time increments
Any of the following may be used:
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on October 18, 2015.