test.equal(moment([2011, 0, 8]).format('DDDo'), '8.', '8.');
test.equal(moment([2011, 0, 9]).format('DDDo'), '9.', '9.');
test.equal(moment([2011, 0, 10]).format('DDDo'), '10.', '10.');
-
+
test.equal(moment([2011, 0, 11]).format('DDDo'), '11.', '11.');
test.equal(moment([2011, 0, 12]).format('DDDo'), '12.', '12.');
test.equal(moment([2011, 0, 13]).format('DDDo'), '13.', '13.');
test.equal(moment([2011, 0, 18]).format('DDDo'), '18.', '18.');
test.equal(moment([2011, 0, 19]).format('DDDo'), '19.', '19.');
test.equal(moment([2011, 0, 20]).format('DDDo'), '20.', '20.');
-
+
test.equal(moment([2011, 0, 21]).format('DDDo'), '21.', '21.');
test.equal(moment([2011, 0, 22]).format('DDDo'), '22.', '22.');
test.equal(moment([2011, 0, 23]).format('DDDo'), '23.', '23.');
test.equal(moment([2011, 0, 28]).format('DDDo'), '28.', '28.');
test.equal(moment([2011, 0, 29]).format('DDDo'), '29.', '29.');
test.equal(moment([2011, 0, 30]).format('DDDo'), '30.', '30.');
-
+
test.equal(moment([2011, 0, 31]).format('DDDo'), '31.', '31.');
test.done();
},
test.equal(start.from(moment([2007, 1, 28]).add({m:90}), true), "2 часа", "90 minutes = 2 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h:5}), true), "5 часов", "5 hours = 5 hours");
test.equal(start.from(moment([2007, 1, 28]).add({h:21}), true), "21 час", "21 hours = 21 hours");
- test.equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "1 день", "22 hours = a day");
- test.equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "1 день", "35 hours = a day");
+ test.equal(start.from(moment([2007, 1, 28]).add({h:22}), true), "день", "22 hours = a day");
+ test.equal(start.from(moment([2007, 1, 28]).add({h:35}), true), "день", "35 hours = a day");
test.equal(start.from(moment([2007, 1, 28]).add({h:36}), true), "2 дня", "36 hours = 2 days");
- test.equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "1 день", "1 day = a day");
+ test.equal(start.from(moment([2007, 1, 28]).add({d:1}), true), "день", "1 day = a day");
test.equal(start.from(moment([2007, 1, 28]).add({d:5}), true), "5 дней", "5 days = 5 days");
test.equal(start.from(moment([2007, 1, 28]).add({d:11}), true), "11 дней", "11 days = 11 days");
test.equal(start.from(moment([2007, 1, 28]).add({d:21}), true), "21 день", "21 days = 21 days");
"calendar day" : function(test) {
test.expect(6);
moment.lang('ru');
-
+
var a = moment().hours(2).minutes(0).seconds(0);
-
+
test.equal(moment(a).calendar(), "Сегодня в 02:00", "today at the same time");
test.equal(moment(a).add({ m: 25 }).calendar(), "Сегодня в 02:25", "Now plus 25 min");
test.equal(moment(a).add({ h: 1 }).calendar(), "Сегодня в 03:00", "Now plus 1 hour");
"calendar next week" : function(test) {
test.expect(15);
moment.lang('ru');
-
+
var i;
var m;
-
+
function makeFormat(d) {
return d.day() === 1 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
}
-
+
for (i = 2; i < 7; i++) {
m = moment().add({ d: i });
test.equal(m.calendar(), m.format(makeFormat(m)), "Today + " + i + " days current time");
"calendar last week" : function(test) {
test.expect(15);
moment.lang('ru');
-
+
var i;
var m;
-
+
function makeFormat(d) {
switch (d.day()) {
case 0:
return '[В прошлую] dddd [в] LT';
}
}
-
+
for (i = 2; i < 7; i++) {
m = moment().subtract({ d: i });
test.equal(m.calendar(), m.format(makeFormat(m)), "Today - " + i + " days current time");
moment.lang('ru');
var weeksAgo = moment().subtract({ w: 1 });
var weeksFromNow = moment().add({ w: 1 });
-
+
test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "1 week ago");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 1 week");
-
+
weeksAgo = moment().subtract({ w: 2 });
weeksFromNow = moment().add({ w: 2 });
-
+
test.equal(weeksAgo.calendar(), weeksAgo.format('L'), "2 weeks ago");
test.equal(weeksFromNow.calendar(), weeksFromNow.format('L'), "in 2 weeks");
test.done();