Time

Time utilities.

Usage

var time = require( '@stdlib/time' );

time

Namespace containing time utilities.

var ns = time;
// returns {...}

Calendar Utilities

var num = time.daysInYear( 2000 );
// returns 366

num = time.hoursInMonth( 2, 2017 );
// returns 672

Timer Utilities

  • tic(): return a high-resolution time.
  • toc( time ): return a high-resolution time difference.
var time = require( '@stdlib/time' );

var start = time.tic();

setTimeout( onTimeout, 2000 );

function onTimeout() {
    var elapsed = time.toc( start );
    console.log( 'Elapsed: %d seconds and %d nanoseconds', elapsed[0], elapsed[1] );
}

Examples

var objectKeys = require( '@stdlib/utils/keys' );
var time = require( '@stdlib/time' );

console.log( objectKeys( time ) );
Did you find this page helpful?