JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 75
  • Score
    100M100P100Q75976F

A module for getting the elapsed time between two dates in various representation.

Package Exports

  • elapsed

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (elapsed) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Elapsed

npm install elapsed

A module for getting the elapsed time between two dates in various representation.

var Elapsed = require('elapsed');

var elapsedTime = new Elapsed(new Date(2013, 05, 2), new Date(2013, 05, 25));

console.log(elapsedTime.minutes.num); // 33120
console.log(elapsedTime.hours.text);  // "552 hours"
console.log(elapsedTime.optimal);     // "3 weeks"

create

var elapsedTime = new Elapsed(from, to);

The from (required) and to (optional, default: now) must be Date objects.

properties

  • milliSeconds: (Object), num property is the time in Number, text is the time in String.
  • seconds: (Object), num property is the time in Number, text is the time in String.
  • minutes: (Object), num property is the time in Number, text is the time in String.
  • hours: (Object), num property is the time in Number, text is the time in String.
  • days: (Object), num property is the time in Number, text is the time in String.
  • weeks: (Object), num property is the time in Number, text is the time in String.
  • months: (Object), num property is the time in Number, text is the time in String.
  • years: (Object), num property is the time in Number, text is the time in String.
  • optimal: (String), the best from the ones above.
  • from: (Date)
  • to: (Date)

methods

  • set(): calculating the properties.
  • refresh(to): refresh the to date. to is optional it defaults to now.