From: Isaac Cambron Date: Tue, 8 Oct 2013 03:53:01 +0000 (-0400) Subject: fix zero index for months() and weekdays() X-Git-Tag: 2.3.1~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1171%2Fhead;p=thirdparty%2Fmoment.git fix zero index for months() and weekdays() --- diff --git a/moment.js b/moment.js index e62b5d502..0bc3a20e9 100644 --- a/moment.js +++ b/moment.js @@ -470,7 +470,7 @@ return method.call(moment.fn._lang, m, format || ''); }; - if (index) { + if (index != null) { return getter(index); } else { diff --git a/test/moment/listers.js b/test/moment/listers.js index 7f9021b4a..86fbbd2d2 100644 --- a/test/moment/listers.js +++ b/test/moment/listers.js @@ -22,11 +22,15 @@ exports.listers = { }, "index" : function (test) { - test.expect(5); + test.equal(moment.months(0), "January"); test.equal(moment.months(2), "March"); + test.equal(moment.monthsShort(0), "Jan"); test.equal(moment.monthsShort(2), "Mar"); + test.equal(moment.weekdays(0), "Sunday"); test.equal(moment.weekdays(2), "Tuesday"); + test.equal(moment.weekdaysShort(0), "Sun"); test.equal(moment.weekdaysShort(2), "Tue"); + test.equal(moment.weekdaysMin(0), "Su"); test.equal(moment.weekdaysMin(2), "Tu"); test.done(); }, @@ -46,13 +50,18 @@ exports.listers = { weekdaysMin: weekdaysMin }); - test.expect(10); test.deepEqual(moment.months(), months); test.deepEqual(moment.monthsShort(), monthsShort); test.deepEqual(moment.weekdays(), weekdays); test.deepEqual(moment.weekdaysShort(), weekdaysShort); test.deepEqual(moment.weekdaysMin(), weekdaysMin); + test.equal(moment.months(0), "one"); + test.equal(moment.monthsShort(0), "on"); + test.equal(moment.weekdays(0), "one"); + test.equal(moment.weekdaysShort(0), "on"); + test.equal(moment.weekdaysMin(0), "1"); + test.equal(moment.months(2), "three"); test.equal(moment.monthsShort(2), "th"); test.equal(moment.weekdays(2), "three");