Socket
Socket
Sign inDemoInstall

humanize-duration

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

humanize-duration - npm Package Compare versions

Comparing version 0.9.0 to 1.0.0

.travis.yml

41

humanize-duration.js

@@ -10,4 +10,16 @@ /*

// What are the languages?
var LANGUAGES = {
// Start by defining the units and how many ms is in each.
var UNITS = [
{ name: "year", milliseconds: 31557600000 },
{ name: "month", milliseconds: 2629800000 },
{ name: "week", milliseconds: 604800000 },
{ name: "day", milliseconds: 86400000 },
{ name: "hour", milliseconds: 3600000 },
{ name: "minute", milliseconds: 60000 },
{ name: "second", milliseconds: 1000 },
{ name: "millisecond", milliseconds: 1 }
];
// Let's also define the default languages.
var languages = {
en: {

@@ -115,14 +127,2 @@ year: function(c) { return "year" + ((c !== 1) ? "s" : ""); },

// Start by defining the units and how many ms is in each.
var UNITS = [
{ name: "year", milliseconds: 31557600000 },
{ name: "month", milliseconds: 2629800000 },
{ name: "week", milliseconds: 604800000 },
{ name: "day", milliseconds: 86400000 },
{ name: "hour", milliseconds: 3600000 },
{ name: "minute", milliseconds: 60000 },
{ name: "second", milliseconds: 1000 },
{ name: "millisecond", milliseconds: 1 }
];
// Internal utility function for rendering the strings.

@@ -133,3 +133,3 @@ // render(1, "minute") == "1 minute"

function render(count, word, language) {
var dictionary = LANGUAGES[language || humanizeDuration.language];
var dictionary = languages[language || humanizeDuration.language];
if (!dictionary) {

@@ -172,3 +172,3 @@ throw new Error("Language " + language + " not defined");

// What are the totals and the rest?
if (unit.name === "millisecond") {
if (unitName === "milliseconds") {
unitCount = ms / unit.milliseconds;

@@ -243,2 +243,11 @@ unitTotal = total / unit.milliseconds;

// How do you add a new language?
humanizeDuration.addLanguage = function addLanguage(name, definition) {
if (languages[name]) {
throw Error("Language " + name + " already defined. If you think this " +
"is an error, please submit a patch!");
}
languages[name] = definition;
};
// What's the default language?

@@ -245,0 +254,0 @@ humanizeDuration.language = "en";

@@ -10,3 +10,3 @@ {

],
"version": "0.9.0",
"version": "1.0.0",
"description": "Convert millisecond durations to English or many other languages.",

@@ -13,0 +13,0 @@ "main": "humanize-duration.js",

Humanize Duration
=================
[![npm version](https://badge.fury.io/js/humanize-duration.svg)](https://npmjs.org/package/humanize-duration)
I have the time in milliseconds and I want it to become "30 minutes" or "3 days, 1 hour". Enter Humanize Duration!

@@ -5,0 +7,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc