Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix zero index for months() and weekdays() #1171

Merged
merged 1 commit into from

2 participants

@icambron
Collaborator

Noticed a bug in months() and company: it doesn't work as expected when you ask for month 0.

@ichernev
Owner

Good catch, thanks!

@ichernev ichernev merged commit 95c86ea into moment:develop
@kkirsche kkirsche referenced this pull request in rubyloco/rubyloco.com
Closed

Update Moment.js to from 2.0 -> 2.9 #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 8, 2013
  1. @icambron
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 3 deletions.
  1. +1 −1  moment.js
  2. +11 −2 test/moment/listers.js
View
2  moment.js
@@ -470,7 +470,7 @@
return method.call(moment.fn._lang, m, format || '');
};
- if (index) {
+ if (index != null) {
return getter(index);
}
else {
View
13 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");
Something went wrong with that request. Please try again.