Skip to content

Commit

Permalink
Spin Button Date Picker Example: Fix February bug (pull #1321)
Browse files Browse the repository at this point in the history
This missing reference was uncovered because this test only fails in February -- for which the function getDaysInMonth had some special handling that lead to an error. Fixed it so the function doesn't error!
  • Loading branch information
spectranaut committed Feb 5, 2020
1 parent b669f13 commit 7aa298f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 72 deletions.
37 changes: 1 addition & 36 deletions examples/spinbutton/js/datepicker-spinbuttons.js
Expand Up @@ -52,42 +52,7 @@ DatePickerSpinButtons.prototype.init = function () {
};

DatePickerSpinButtons.prototype.getDaysInMonth = function (year, month) {

if (typeof year !== 'number') {
year = this.year;
}

if (typeof month !== 'number') {
month = this.month;
}

switch (month) {

case 0:
case 2:
case 4:
case 6:
case 7:
case 9:
case 11:
return 31;

case 1:
return (((this.yearIndex % 4 === 0) && (this.yearIndex % 100 !== 0) && (this.yearIndex % 400 === 0)) ? 29 : 28);

case 3:
case 5:
case 8:
case 10:
return 30;

default:
break;

}

return -1;

return new Date(year, month + 1, 0).getDate();
};

DatePickerSpinButtons.prototype.updateDay = function (day) {
Expand Down
37 changes: 1 addition & 36 deletions test/tests/spinbutton_datepicker.js
Expand Up @@ -13,42 +13,7 @@ const valuesMonth = ['January', 'February', 'March', 'April', 'May', 'June', 'Ju


var getDaysInMonth = function (year, month) {

if (typeof year !== 'number') {
year = this.year;
}

if (typeof month !== 'number') {
month = this.month;
}

switch (month) {

case 0:
case 2:
case 4:
case 6:
case 7:
case 9:
case 11:
return 31;

case 1:
return (((this.yearIndex % 4 === 0) && (this.yearIndex % 100 !== 0) && (this.yearIndex % 400 === 0)) ? 29 : 28);

case 3:
case 5:
case 8:
case 10:
return 30;

default:
break;

}

return -1;

return new Date(year, month + 1, 0).getDate();
};

var d = new Date();
Expand Down

0 comments on commit 7aa298f

Please sign in to comment.