Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
elapsed
Advanced tools
Readme
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"
var elapsedTime = new Elapsed(from, to, i10n);
The from
(required) and to
(optional, default: now) must be Date
objects. i10n
(optional: default: english) must be a plain object.
num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.num
property is the time in Number, text
is the time in String.to
date. to
is optional it defaults to now.If you want to localize the elapsed time, you can provide an object holding the translations by passing it into the constructor as a third argument.
var i10n = {…};
var elapsedTime = new Elapsed(from, to, i10n);
Take a look at the english version, to get an impression of how the object should look like:
var i10n = {
milliSeconds: ['millisecond', 's'],
seconds: ['second', 's'],
minutes: ['minute', 's'],
hours: ['hour', 's'],
days: ['day', 's'],
weeks: ['week', 's'],
months: ['month', 's'],
years: ['year', 's']
};
Each property holds an array containing the singular and the plural-suffix.
If you don't need to specify the to
-parameter, you can pass in the localization as second parameter:
var i10n = {…};
var elapsedTime = new Elapsed(from, i10n);
FAQs
A module for getting the elapsed time between two dates in various representation.
The npm package elapsed receives a total of 25 weekly downloads. As such, elapsed popularity was classified as not popular.
We found that elapsed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.