Skip to content

Instantly share code, notes, and snippets.

@mfd
Last active September 23, 2017 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfd/024ba2f3ae5e43dfbdd15b3de8a3edc8 to your computer and use it in GitHub Desktop.
Save mfd/024ba2f3ae5e43dfbdd15b3de8a3edc8 to your computer and use it in GitHub Desktop.
cyrillic pluralize
var t = {
d: 6,
h: 5,
m: 23,
s: 53
}
var pluralize = function(t, e) {
var s = void 0
, n = e % 100;
return n >= 5 && n <= 20 ? s = t[2] : (n %= 10,
s = 1 == n ? t[0] : n >= 2 && n <= 4 ? t[1] : t[2]),
s
}
console.log(t.d + ' ' + pluralize(["День", "Дня", "Дней"], t.d));
console.log(t.h + ' ' + pluralize(["Час", "Часа", "Часов"], t.h));
console.log(t.m + ' ' + pluralize(["Минута", "Минуты", "Минут"], t.m));
console.log(t.s + ' ' + pluralize(["Секунда", "Секунды", "Секунд"], t.s));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment