mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 15:09:16 +08:00
[Improvement] DatetimePicker: refactor getMonthEndDay function (#1847)
This commit is contained in:
parent
efa264d612
commit
40d965db67
@ -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() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user