sameElse: 'L'
},
relativeTime : {
- future : "%sран",
+ future : function(output) {
+ var affix = /сехет$/i.exec(output)
+ ? "рен" : /çул$/i.exec(output) ? "тан" : "ран";
+ return output + affix;
+ },
past : "%s каялла",
s : "пĕр-ик çеккунт",
m : "пĕр минут",
humanize : function (withSuffix) {
var difference = +this,
rel = this.lang().relativeTime,
- output = relativeTime(difference, !withSuffix, this.lang());
+ output = relativeTime(difference, !withSuffix, this.lang()),
+ fromNow = difference <= 0 ? rel.past : rel.future;
if (withSuffix) {
- output = (difference <= 0 ? rel.past : rel.future).replace(/%s/i, output);
+ if (typeof fromNow === 'function') {
+ output = fromNow(output);
+ }
+ else {
+ output = fromNow.replace(/%s/i, output);
+ }
}
return output;
},
"fromNow" : function(test) {
- test.expect(2);
+ test.expect(4);
moment.lang('cv');
test.equal(moment().add({s:30}).fromNow(), "пĕр-ик çеккунтран", "in a few seconds");
test.equal(moment().add({d:5}).fromNow(), "5 кунран", "in 5 days");
+ test.equal(moment().add({h:2}).fromNow(), "2 сехетрен", "in 2 hours, the right suffix!");
+ test.equal(moment().add({y:3}).fromNow(), "3 çултан", "in 3 years, the right suffix!");
test.done();
},