web/console/node_modules/date-difference/index.js
/*
The datePrettyFormat function converts milliseconds to a human readible
date output that corresponds to a specific format.
*/
The datePrettyFormat function converts milliseconds to a human readible
date output that corresponds to a specific format.
The datePrettyFormat function converts milliseconds to a human readible date output that corresponds to a specific format .
function datePrettyFormat(ms, opts) {
  if (typeof ms !== 'number') {
    throw new TypeError('Expected a number');
  }
  if (ms < 1000) {
    return Math.ceil(ms) + 'ms';
  }
  opts = opts || {};
  var secDecimalDigits = typeof opts.secDecimalDigits === 'number' ? opts.secDecimalDigits : 1;
  var ret = [];
  var parsed = formatDate(ms);
  ret = add(ret, parsed.years, 'y');
  ret = add(ret, parsed.days, 'd');
  ret = add(ret, parsed.hours, 'h');
  ret = add(ret, parsed.minutes, 'm');
  if (opts.compact) {
    ret = add(ret, parsed.seconds, 's');
    return '~' + ret[0];
  }
  ret = add(ret, (ms / 1000 % 60).toFixed(secDecimalDigits).replace(/\.0$/, ''), 's');
  return ret.join(' ');
}
function datePrettyFormat ( ms , opts ) { if ( typeof ms !== 'number' ) { throw new TypeError ( 'Expected a number' ) ; } if ( ms < 1000 ) { return Math . ceil ( ms ) + 'ms' ; } opts = opts || { } ; var secDecimalDigits = typeof opts . secDecimalDigits === 'number' ? opts . secDecimalDigits : 1 ; var ret = [ ] ; var parsed = formatDate ( ms ) ; ret = add ( ret , parsed . years , 'y' ) ; ret = add ( ret , parsed . days , 'd' ) ; ret = add ( ret , parsed . hours , 'h' ) ; ret = add ( ret , parsed . minutes , 'm' ) ; if ( opts . compact ) { ret = add ( ret , parsed . seconds , 's' ) ; return '~' + ret [ 0 ] ; } ret = add ( ret , ( ms / 1000 % 60 ) . toFixed ( secDecimalDigits ) . replace ( / \.0$ / , '' ) , 's' ) ; return ret . join ( ' ' ) ; }
The datePrettyFormat function converts milliseconds to a human readible
date output that corresponds to a specific format.
The datePrettyFormat function converts milliseconds to a human readible date output that corresponds to a specific format .