Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 1.0.0 to 1.1.0

test/test-russian.coffee

5

bower.json

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

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

@@ -33,3 +33,4 @@ "main": "humanize-duration.js",

"german",
"danish"
"danish",
"russian"
],

@@ -36,0 +37,0 @@ "license": "WTFPL",

105

humanize-duration.js

@@ -24,2 +24,32 @@ /*

var languages = {
ca: {
year: function(c) { return "any" + ((c !== 1) ? "s" : ""); },
month: function(c) { return "mes" + ((c !== 1) ? "os" : ""); },
week: function(c) { return "setman" + ((c !== 1) ? "es" :"a"); },
day: function(c) { return "di" + ((c !== 1) ? "es" :"a"); },
hour: function(c) { return "hor" + ((c !== 1) ? "es" :"a"); },
minute: function(c) { return "minut" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segon" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milisegon" + ((c !== 1) ? "s" : "" ); }
},
da: {
year: function() { return "år"; },
month: function(c) { return "måned" + ((c !== 1) ? "er" : ""); },
week: function(c) { return "uge" + ((c !== 1) ? "r" : ""); },
day: function(c) { return "dag" + ((c !== 1) ? "e" : ""); },
hour: function(c) { return "time" + ((c !== 1) ? "r" : ""); },
minute: function(c) { return "minut" + ((c !== 1) ? "ter" : ""); },
second: function(c) { return "sekund" + ((c !== 1) ? "er" : ""); },
millisecond: function(c) { return "millisekund" + ((c !== 1) ? "er" : ""); }
},
de: {
year: function(c) { return "jahr" + ((c !== 1) ? "e" : ""); },
month: function(c) { return "monat" + ((c !== 1) ? "e" : ""); },
week: function(c) { return "woche" + ((c !== 1) ? "n" : ""); },
day: function(c) { return "tag" + ((c !== 1) ? "e" : ""); },
hour: function(c) { return "stunde" + ((c !== 1) ? "n" : ""); },
minute: function(c) { return "minute" + ((c !== 1) ? "n" : ""); },
second: function(c) { return "sekunde" + ((c !== 1) ? "n" : ""); },
millisecond: function(c) { return "millisekunde" + ((c !== 1) ? "n" : ""); }
},
en: {

@@ -35,12 +65,2 @@ year: function(c) { return "year" + ((c !== 1) ? "s" : ""); },

},
ca: {
year: function(c) { return "any" + ((c !== 1) ? "s" : ""); },
month: function(c) { return "mes" + ((c !== 1) ? "os" : ""); },
week: function(c) { return "setman" + ((c !== 1) ? "es" :"a"); },
day: function(c) { return "di" + ((c !== 1) ? "es" :"a"); },
hour: function(c) { return "hor" + ((c !== 1) ? "es" :"a"); },
minute: function(c) { return "minut" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segon" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milisegon" + ((c !== 1) ? "s" : "" ); }
},
es: {

@@ -66,12 +86,2 @@ year: function(c) { return "año" + ((c !== 1) ? "s" : ""); },

},
pt: {
year: function(c) { return "ano" + ((c !== 1) ? "s" : ""); },
month: function(c) { return (c !== 1) ? "meses" : "mês"; },
week: function(c) { return "semana" + ((c !== 1) ? "s" : ""); },
day: function(c) { return "dia" + ((c !== 1) ? "s" : ""); },
hour: function(c) { return "hora" + ((c !== 1) ? "s" : ""); },
minute: function(c) { return "minuto" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segundo" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milissegundo" + ((c !== 1) ? "s" : ""); }
},
ko: {

@@ -97,12 +107,2 @@ year: function() { return "년"; },

},
de: {
year: function(c) { return "jahr" + ((c !== 1) ? "e" : ""); },
month: function(c) { return "monat" + ((c !== 1) ? "e" : ""); },
week: function(c) { return "woche" + ((c !== 1) ? "n" : ""); },
day: function(c) { return "tag" + ((c !== 1) ? "e" : ""); },
hour: function(c) { return "stunde" + ((c !== 1) ? "n" : ""); },
minute: function(c) { return "minute" + ((c !== 1) ? "n" : ""); },
second: function(c) { return "sekunde" + ((c !== 1) ? "n" : ""); },
millisecond: function(c) { return "millisekunde" + ((c !== 1) ? "n" : ""); }
},
pl: {

@@ -118,11 +118,21 @@ year: function(c) { return ["rok", "roku", "lata", "lat"][getPolishForm(c)]; },

},
da: {
year: function() { return "år"; },
month: function(c) { return "måned" + ((c !== 1) ? "er" : ""); },
week: function(c) { return "uge" + ((c !== 1) ? "r" : ""); },
day: function(c) { return "dag" + ((c !== 1) ? "e" : ""); },
hour: function(c) { return "time" + ((c !== 1) ? "r" : ""); },
minute: function(c) { return "minut" + ((c !== 1) ? "ter" : ""); },
second: function(c) { return "sekund" + ((c !== 1) ? "er" : ""); },
millisecond: function(c) { return "millisekund" + ((c !== 1) ? "er" : ""); }
pt: {
year: function(c) { return "ano" + ((c !== 1) ? "s" : ""); },
month: function(c) { return (c !== 1) ? "meses" : "mês"; },
week: function(c) { return "semana" + ((c !== 1) ? "s" : ""); },
day: function(c) { return "dia" + ((c !== 1) ? "s" : ""); },
hour: function(c) { return "hora" + ((c !== 1) ? "s" : ""); },
minute: function(c) { return "minuto" + ((c !== 1) ? "s" : ""); },
second: function(c) { return "segundo" + ((c !== 1) ? "s" : ""); },
millisecond: function(c) { return "milissegundo" + ((c !== 1) ? "s" : ""); }
},
ru: {
year: function(c) { return ["лет", "год", "года"][getRussianForm(c)]; },
month: function(c) { return ["месяцев", "месяц", "месяца"][getRussianForm(c)]; },
week: function(c) { return ["недель", "неделя", "недели"][getRussianForm(c)]; },
day: function(c) { return ["дней", "день", "дня"][getRussianForm(c)]; },
hour: function(c) { return ["часов", "час", "часа"][getRussianForm(c)]; },
minute: function(c) { return ["минут", "минута", "минуты"][getRussianForm(c)]; },
second: function(c) { return ["секунд", "секунда", "секунды"][getRussianForm(c)]; },
millisecond: function(c) { return ["миллисекунд", "миллисекунда", "миллисекунды"][getRussianForm(c)]; }
}

@@ -143,2 +153,17 @@ };

// Internal helper function for Russian language.
function getRussianForm(c) {
if (Math.floor(c) !== c) {
return 2;
} else if (c === 0 || (c >= 5 && c <= 20) || (c % 10 >= 5 && c % 10 <= 9) || (c % 10 === 0) ) {
return 0;
} else if (c === 1 || c % 10 === 1) {
return 1;
} else if (c > 1) {
return 2;
} else {
return 0;
}
}
// Internal helper function for Polish language.

@@ -248,3 +273,3 @@ function getPolishForm(c) {

if (languages[name]) {
throw Error("Language " + name + " already defined. If you think this " +
throw new Error("Language " + name + " already defined. If you think this " +
"is an error, please submit a patch!");

@@ -251,0 +276,0 @@ }

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

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

@@ -43,3 +43,4 @@ "main": "humanize-duration.js",

"german",
"danish"
"danish",
"russian"
],

@@ -46,0 +47,0 @@ "jshintConfig": {

@@ -5,2 +5,3 @@ Humanize Duration

[![npm version](https://badge.fury.io/js/humanize-duration.svg)](https://npmjs.org/package/humanize-duration)
[![build status](https://travis-ci.org/EvanHahn/HumanizeDuration.js.svg?branch=master)](https://travis-ci.org/EvanHahn/HumanizeDuration.js)

@@ -24,2 +25,4 @@ I have the time in milliseconds and I want it to become "30 minutes" or "3 days, 1 hour". Enter Humanize Duration!

Also available for Bower as *humanize-duration*.
Here's some basic usage:

@@ -73,2 +76,3 @@

* Spanish (es)
* Russian (ru)

@@ -75,0 +79,0 @@ Credits

Sorry, the diff of this file is not supported yet

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