"format" : function (test) {
test.expect(22);
var a = [
- ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد, فبراير/ شباط 14 2010, 3:25:50 pm'],
- ['ddd, hA', 'اÙ\84Ø£ØØ¯, 3PM'],
- ['M Mo MM MMMM MMM', '2 2 02 فبراير/ شباط فبراير/ شباط'],
- ['YYYY YY', '2010 10'],
- ['D Do DD', '14 14 14'],
- ['d do dddd ddd dd', '0 0 الأحد الأحد ح'],
- ['DDD DDDo DDDD', '45 45 045'],
- ['w wo ww', '8 8 08'],
- ['h hh', '3 03'],
- ['H HH', '15 15'],
- ['m mm', '25 25'],
- ['s ss', '50 50'],
- ['a A', 'pm PM'],
- ['[the] DDDo [day of the year]', 'the 45 day of the year'],
- ['L', '14/02/2010'],
- ['LL', '14 فبراير/ شباط 2010'],
- ['LLL', '14 فبراير/ شباط 2010 15:25'],
- ['LLLL', 'الأحد 14 فبراير/ شباط 2010 15:25'],
- ['l', '14/2/2010'],
- ['ll', '14 فبراير/ شباط 2010'],
- ['lll', '14 فبراير/ شباط 2010 15:25'],
- ['llll', 'اÙ\84Ø£ØØ¯ 14 Ù\81براÙ\8aر/ شباط 2010 15:25']
+ ['dddd, MMMM Do YYYY, h:mm:ss a', 'الأحد، فبراير/ شباط ١٤ ٢٠١٠، ٣:٢٥:٥٠ م'],
+ ['ddd, hA', 'Ø£ØØ¯Ø\8c Ù£Ù\85'],
+ ['M Mo MM MMMM MMM', '٢ ٢ ٠٢ فبراير/ شباط فبراير/ شباط'],
+ ['YYYY YY', '٢٠١٠ ١٠'],
+ ['D Do DD', '١٤ ١٤ ١٤'],
+ ['d do dddd ddd dd', '٠ ٠ الأحد أحد ح'],
+ ['DDD DDDo DDDD', '٤٥ ٤٥ ٠٤٥'],
+ ['w wo ww', '٨ ٨ ٠٨'],
+ ['h hh', '٣ ٠٣'],
+ ['H HH', '١٥ ١٥'],
+ ['m mm', '٢٥ ٢٥'],
+ ['s ss', '٥٠ ٥٠'],
+ ['a A', 'م م'],
+ ['[the] DDDo [day of the year]', 'the ٤٥ day of the year'],
+ ['L', '١٤/٠٢/٢٠١٠'],
+ ['LL', '١٤ فبراير/ شباط ٢٠١٠'],
+ ['LLL', '١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'],
+ ['LLLL', 'الأحد ١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'],
+ ['l', '١٤/٢/٢٠١٠'],
+ ['ll', '١٤ فبراير/ شباط ٢٠١٠'],
+ ['lll', '١٤ فبراير/ شباط ٢٠١٠ ١٥:٢٥'],
+ ['llll', 'Ø£ØØ¯ ١٤ Ù\81براÙ\8aر/ شباط ٢٠١٠١٥:٢٥']
],
b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)),
i;
"format ordinal" : function (test) {
test.expect(31);
- test.equal(moment([2011, 0, 1]).format('DDDo'), '1', '1');
- test.equal(moment([2011, 0, 2]).format('DDDo'), '2', '2');
- test.equal(moment([2011, 0, 3]).format('DDDo'), '3', '3');
- test.equal(moment([2011, 0, 4]).format('DDDo'), '4', '4');
- test.equal(moment([2011, 0, 5]).format('DDDo'), '5', '5');
- test.equal(moment([2011, 0, 6]).format('DDDo'), '6', '6');
- test.equal(moment([2011, 0, 7]).format('DDDo'), '7', '7');
- 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, 14]).format('DDDo'), '14', '14');
- test.equal(moment([2011, 0, 15]).format('DDDo'), '15', '15');
- test.equal(moment([2011, 0, 16]).format('DDDo'), '16', '16');
- test.equal(moment([2011, 0, 17]).format('DDDo'), '17', '17');
- 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, 24]).format('DDDo'), '24', '24');
- test.equal(moment([2011, 0, 25]).format('DDDo'), '25', '25');
- test.equal(moment([2011, 0, 26]).format('DDDo'), '26', '26');
- test.equal(moment([2011, 0, 27]).format('DDDo'), '27', '27');
- 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.equal(moment([2011, 0, 1]).format('DDDo'), '١', '1');
+ test.equal(moment([2011, 0, 2]).format('DDDo'), '٢', '2');
+ test.equal(moment([2011, 0, 3]).format('DDDo'), '٣', '3');
+ test.equal(moment([2011, 0, 4]).format('DDDo'), '٤', '4');
+ test.equal(moment([2011, 0, 5]).format('DDDo'), '٥', '5');
+ test.equal(moment([2011, 0, 6]).format('DDDo'), '٦', '6');
+ test.equal(moment([2011, 0, 7]).format('DDDo'), '٧', '7');
+ test.equal(moment([2011, 0, 8]).format('DDDo'), '٨', '8');
+ test.equal(moment([2011, 0, 9]).format('DDDo'), '٩', '9');
+ test.equal(moment([2011, 0, 10]).format('DDDo'), '١٠', '10');
+
+ test.equal(moment([2011, 0, 11]).format('DDDo'), '١١', '11');
+ test.equal(moment([2011, 0, 12]).format('DDDo'), '١٢', '12');
+ test.equal(moment([2011, 0, 13]).format('DDDo'), '١٣', '13');
+ test.equal(moment([2011, 0, 14]).format('DDDo'), '١٤', '14');
+ test.equal(moment([2011, 0, 15]).format('DDDo'), '١٥', '15');
+ test.equal(moment([2011, 0, 16]).format('DDDo'), '١٦', '16');
+ test.equal(moment([2011, 0, 17]).format('DDDo'), '١٧', '17');
+ test.equal(moment([2011, 0, 18]).format('DDDo'), '١٨', '18');
+ test.equal(moment([2011, 0, 19]).format('DDDo'), '١٩', '19');
+ test.equal(moment([2011, 0, 20]).format('DDDo'), '٢٠', '20');
+
+ test.equal(moment([2011, 0, 21]).format('DDDo'), '٢١', '21');
+ test.equal(moment([2011, 0, 22]).format('DDDo'), '٢٢', '22');
+ test.equal(moment([2011, 0, 23]).format('DDDo'), '٢٣', '23');
+ test.equal(moment([2011, 0, 24]).format('DDDo'), '٢٤', '24');
+ test.equal(moment([2011, 0, 25]).format('DDDo'), '٢٥', '25');
+ test.equal(moment([2011, 0, 26]).format('DDDo'), '٢٦', '26');
+ test.equal(moment([2011, 0, 27]).format('DDDo'), '٢٧', '27');
+ test.equal(moment([2011, 0, 28]).format('DDDo'), '٢٨', '28');
+ test.equal(moment([2011, 0, 29]).format('DDDo'), '٢٩', '29');
+ test.equal(moment([2011, 0, 30]).format('DDDo'), '٣٠', '30');
+
+ test.equal(moment([2011, 0, 31]).format('DDDo'), '٣١', '31');
test.done();
},
"format week" : function (test) {
test.expect(7);
- var expected = 'اÙ\84Ø£ØØ¯ اÙ\84Ø£ØØ¯ Ø_اÙ\84إثÙ\86Ù\8aÙ\86 اÙ\84إثÙ\86Ù\8aÙ\86 Ù\86_اÙ\84Ø«Ù\84اثاء اÙ\84Ø«Ù\84اثاء Ø«_اÙ\84أربعاء اÙ\84أربعاء ر_اÙ\84Ø®Ù\85Ù\8aس اÙ\84Ø®Ù\85Ù\8aس Ø®_اÙ\84جÙ\85عة اÙ\84جÙ\85عة ج_اÙ\84سبت اÙ\84سبت س'.split("_"), i;
+ var expected = 'اÙ\84Ø£ØØ¯ Ø£ØØ¯ Ø_اÙ\84إثÙ\86Ù\8aÙ\86 إثÙ\86Ù\8aÙ\86 Ù\86_اÙ\84Ø«Ù\84اثاء Ø«Ù\84اثاء Ø«_اÙ\84أربعاء أربعاء ر_اÙ\84Ø®Ù\85Ù\8aس Ø®Ù\85Ù\8aس Ø®_اÙ\84جÙ\85عة جÙ\85عة ج_اÙ\84سبت سبت س'.split("_"), i;
for (i = 0; i < expected.length; i++) {
test.equal(moment([2011, 0, 2 + i]).format('dddd ddd dd'), expected[i], expected[i]);
}
test.equal(start.from(moment([2007, 1, 28]).add({s: 44}), true), "ثوان", "44 seconds = a few seconds");
test.equal(start.from(moment([2007, 1, 28]).add({s: 45}), true), "دقيقة", "45 seconds = a minute");
test.equal(start.from(moment([2007, 1, 28]).add({s: 89}), true), "دقيقة", "89 seconds = a minute");
- test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "2 دقائق", "90 seconds = 2 minutes");
- test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "44 دقائق", "44 minutes = 44 minutes");
+ test.equal(start.from(moment([2007, 1, 28]).add({s: 90}), true), "٢ دقائق", "90 seconds = 2 minutes");
+ test.equal(start.from(moment([2007, 1, 28]).add({m: 44}), true), "٤٤ دقائق", "44 minutes = 44 minutes");
test.equal(start.from(moment([2007, 1, 28]).add({m: 45}), true), "ساعة", "45 minutes = an hour");
test.equal(start.from(moment([2007, 1, 28]).add({m: 89}), true), "ساعة", "89 minutes = an hour");
- 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({m: 90}), true), "٢ ساعات", "90 minutes = 2 hours");
+ test.equal(start.from(moment([2007, 1, 28]).add({h: 5}), true), "٥ ساعات", "5 hours = 5 hours");
+ test.equal(start.from(moment([2007, 1, 28]).add({h: 21}), true), "٢١ ساعات", "21 hours = 21 hours");
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({h: 36}), true), "٢ أيام", "36 hours = 2 days");
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: 25}), true), "25 أيام", "25 days = 25 days");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 5}), true), "٥ أيام", "5 days = 5 days");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 25}), true), "٢٥ أيام", "25 days = 25 days");
test.equal(start.from(moment([2007, 1, 28]).add({d: 26}), true), "شهر", "26 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 30}), true), "شهر", "30 days = a month");
test.equal(start.from(moment([2007, 1, 28]).add({d: 45}), true), "شهر", "45 days = a month");
- test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "2 أشهر", "46 days = 2 months");
- test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "2 أشهر", "75 days = 2 months");
- test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "3 أشهر", "76 days = 3 months");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 46}), true), "٢ أشهر", "46 days = 2 months");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 74}), true), "٢ أشهر", "75 days = 2 months");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 76}), true), "٣ أشهر", "76 days = 3 months");
test.equal(start.from(moment([2007, 1, 28]).add({M: 1}), true), "شهر", "1 month = a month");
- test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "5 أشهر", "5 months = 5 months");
- test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "11 أشهر", "344 days = 11 months");
+ test.equal(start.from(moment([2007, 1, 28]).add({M: 5}), true), "٥ أشهر", "5 months = 5 months");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 344}), true), "١١ أشهر", "344 days = 11 months");
test.equal(start.from(moment([2007, 1, 28]).add({d: 345}), true), "سنة", "345 days = a year");
test.equal(start.from(moment([2007, 1, 28]).add({d: 547}), true), "سنة", "547 days = a year");
- test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "2 سنوات", "548 days = 2 years");
+ test.equal(start.from(moment([2007, 1, 28]).add({d: 548}), true), "٢ سنوات", "548 days = 2 years");
test.equal(start.from(moment([2007, 1, 28]).add({y: 1}), true), "سنة", "1 year = a year");
- test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "5 سنوات", "5 years = 5 years");
+ test.equal(start.from(moment([2007, 1, 28]).add({y: 5}), true), "٥ سنوات", "5 years = 5 years");
test.done();
},
"fromNow" : function (test) {
test.expect(2);
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({d: 5}).fromNow(), "في ٥ أيام", "in 5 days");
test.done();
},
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");
- test.equal(moment(a).add({ d: 1 }).calendar(), "غدا على الساعة 02:00", "tomorrow at the same time");
- test.equal(moment(a).subtract({ h: 1 }).calendar(), "اليوم على الساعة 01:00", "Now minus 1 hour");
- test.equal(moment(a).subtract({ d: 1 }).calendar(), "أمس على الساعة 02:00", "yesterday at the same time");
+ test.equal(moment(a).calendar(), "اليوم على الساعة ٠٢:٠٠", "today at the same time");
+ test.equal(moment(a).add({ m: 25 }).calendar(), "اليوم على الساعة ٠٢:٢٥", "Now plus 25 min");
+ test.equal(moment(a).add({ h: 1 }).calendar(), "اليوم على الساعة ٠٣:٠٠", "Now plus 1 hour");
+ test.equal(moment(a).add({ d: 1 }).calendar(), "غدا على الساعة ٠٢:٠٠", "tomorrow at the same time");
+ test.equal(moment(a).subtract({ h: 1 }).calendar(), "اليوم على الساعة ٠١:٠٠", "Now minus 1 hour");
+ test.equal(moment(a).subtract({ d: 1 }).calendar(), "أمس على الساعة ٠٢:٠٠", "yesterday at the same time");
test.done();
},
test.equal(moment([2003, 0, 10]).week(), 2, "Jan 10 2003 should be week 2");
test.equal(moment([2003, 0, 11]).week(), 3, "Jan 11 2003 should be week 3");
- test.equal(moment("2003 1 6", "gggg w d").format("YYYY-MM-DD"), "2002-12-28", "Week 1 of 2003 should be Dec 28 2002");
- test.equal(moment("2003 1 0", "gggg w e").format("YYYY-MM-DD"), "2002-12-28", "Week 1 of 2003 should be Dec 28 2002");
- test.equal(moment("2003 1 6", "gggg w d").format("gggg w d"), "2003 1 6", "Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6");
- test.equal(moment("2003 1 0", "gggg w e").format("gggg w e"), "2003 1 0", "1st day of week 1 of 2003 parsed should be formatted as 2003 1 0");
+ test.equal(moment("2003 1 6", "gggg w d").format("YYYY-MM-DD"), "٢٠٠٢-١٢-٢٨", "Week 1 of 2003 should be Dec 28 2002");
+ test.equal(moment("2003 1 0", "gggg w e").format("YYYY-MM-DD"), "٢٠٠٢-١٢-٢٨", "Week 1 of 2003 should be Dec 28 2002");
+ test.equal(moment("2003 1 6", "gggg w d").format("gggg w d"), "٢٠٠٣ ١ ٦", "Saturday of week 1 of 2003 parsed should be formatted as 2003 1 6");
+ test.equal(moment("2003 1 0", "gggg w e").format("gggg w e"), "٢٠٠٣ ١ ٠", "1st day of week 1 of 2003 parsed should be formatted as 2003 1 0");
test.done();
},
"weeks year starting sunday formatted" : function (test) {
test.expect(5);
- test.equal(moment([2011, 11, 31]).format('w ww wo'), '1 01 1', "Dec 31 2011 should be week 1");
- test.equal(moment([2012, 0, 6]).format('w ww wo'), '1 01 1', "Jan 6 2012 should be week 1");
- test.equal(moment([2012, 0, 7]).format('w ww wo'), '2 02 2', "Jan 7 2012 should be week 2");
- test.equal(moment([2012, 0, 13]).format('w ww wo'), '2 02 2', "Jan 13 2012 should be week 2");
- test.equal(moment([2012, 0, 14]).format('w ww wo'), '3 03 3', "Jan 14 2012 should be week 3");
+ test.equal(moment([2011, 11, 31]).format('w ww wo'), '١ ٠١ ١', "Dec 31 2011 should be week 1");
+ test.equal(moment([2012, 0, 6]).format('w ww wo'), '١ ٠١ ١', "Jan 6 2012 should be week 1");
+ test.equal(moment([2012, 0, 7]).format('w ww wo'), '٢ ٠٢ ٢', "Jan 7 2012 should be week 2");
+ test.equal(moment([2012, 0, 13]).format('w ww wo'), '٢ ٠٢ ٢', "Jan 13 2012 should be week 2");
+ test.equal(moment([2012, 0, 14]).format('w ww wo'), '٣ ٠٣ ٣', "Jan 14 2012 should be week 3");
test.done();
},