现在世界通用的公历(阳历)也经过一个长期演变的过程。我们先看,公历每个月的日数是固定的:
"七前单大,八后双大"。也就是说,一、三、五、七、八、十、腊月(十二月)是31天,
四、六、九、十一月是30天,只有二月,平年28天,闰年29天。
let cascader={
creatYear () {
let years = []
let year = new Date().getFullYear()
let minYear = year - 100
for (let i = year; i >= minYear; i--) {
years.push(i)
}
this.years = years
},
creatMonth () {
let months = []
for (let i = 0; i < 12; i++) {
months.push(i + 1)
}
this.months = months
},
creatDay (year, month) {
let days = []
let day
switch (month) {
case 1:
case 3:
case 7:
case 8:
case 10:
case 12:
day = 31
break
case 4:
case 6:
case 9:
case 11:
day = 30
break
case 2:
day = IsRunYear(year) ? 29 : 28
break
default:
day = 31
}
function IsRunYear (year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0
}
for (let i = 0; i < day; i++) {
days.push(i + 1)
}
return days
}
}