From 71268c5babaecb383fdce87d68fb98f7d37ed4ac Mon Sep 17 00:00:00 2001 From: Due07 <81630137+Due07@users.noreply.github.com> Date: Tue, 13 Sep 2022 14:40:27 +0800 Subject: [PATCH] Utils: update date-util.js (#22099) Co-authored-by: xulongtai --- src/utils/date-util.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/utils/date-util.js b/src/utils/date-util.js index 1828adfc2..9e8a2f4af 100644 --- a/src/utils/date-util.js +++ b/src/utils/date-util.js @@ -48,19 +48,9 @@ export const parseDate = function(string, format) { }; export const getDayCountOfMonth = function(year, month) { - if (month === 3 || month === 5 || month === 8 || month === 10) { - return 30; - } + if (isNaN(+month)) return 31; - if (month === 1) { - if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) { - return 29; - } else { - return 28; - } - } - - return 31; + return new Date(year, +month + 1, 0).getDate(); }; export const getDayCountOfYear = function(year) {