Skip to content

Commit 71268c5

Browse files
Due07xulongtai
andauthored
Utils: update date-util.js (#22099)
Co-authored-by: xulongtai <[email protected]>
1 parent acfc93a commit 71268c5

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/utils/date-util.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,9 @@ export const parseDate = function(string, format) {
4848
};
4949

5050
export const getDayCountOfMonth = function(year, month) {
51-
if (month === 3 || month === 5 || month === 8 || month === 10) {
52-
return 30;
53-
}
54-
55-
if (month === 1) {
56-
if (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) {
57-
return 29;
58-
} else {
59-
return 28;
60-
}
61-
}
51+
if (isNaN(+month)) return 31;
6252

63-
return 31;
53+
return new Date(year, +month + 1, 0).getDate();
6454
};
6555

6656
export const getDayCountOfYear = function(year) {

0 commit comments

Comments
 (0)