diff --git a/examples/spinbutton/js/datepicker-spinbuttons.js b/examples/spinbutton/js/datepicker-spinbuttons.js index 9b6f54a222..7095b4618d 100644 --- a/examples/spinbutton/js/datepicker-spinbuttons.js +++ b/examples/spinbutton/js/datepicker-spinbuttons.js @@ -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) { diff --git a/test/tests/spinbutton_datepicker.js b/test/tests/spinbutton_datepicker.js index 7777979376..f0bab68adc 100644 --- a/test/tests/spinbutton_datepicker.js +++ b/test/tests/spinbutton_datepicker.js @@ -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();