From 40d965db67b9f7c86c4572c960a7b7b45639ef0a Mon Sep 17 00:00:00 2001 From: Ryanx Chen Date: Sun, 23 Sep 2018 14:50:41 +0800 Subject: [PATCH] [Improvement] DatetimePicker: refactor getMonthEndDay function (#1847) --- packages/datetime-picker/index.vue | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/packages/datetime-picker/index.vue b/packages/datetime-picker/index.vue index c81fd45d1..176b7be22 100644 --- a/packages/datetime-picker/index.vue +++ b/packages/datetime-picker/index.vue @@ -256,21 +256,7 @@ export default create({ }, getMonthEndDay(year, month) { - if (this.isShortMonth(month)) { - 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; + return 32 - new Date(year, month - 1, 32).getDate(); }, onConfirm() {