[Improvement] DatetimePicker: refactor getMonthEndDay function (#1847)

This commit is contained in:
Ryanx Chen 2018-09-23 14:50:41 +08:00 committed by neverland
parent efa264d612
commit 40d965db67

View File

@ -256,21 +256,7 @@ export default create({
}, },
getMonthEndDay(year, month) { getMonthEndDay(year, month) {
if (this.isShortMonth(month)) { return 32 - new Date(year, month - 1, 32).getDate();
return 30;
} else if (month === 2) {
return this.isLeapYear(year) ? 29 : 28;
} else {
return 31;
}
},
isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
},
isShortMonth(month) {
return [4, 6, 9, 11].indexOf(month) > -1;
}, },
onConfirm() { onConfirm() {