this.years = []
for (let i = 1970
this.years.push(i)
}
this.months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
this.daysCount = [
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
]
isLeapYear(year) {
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0)
}
let daysCount = this.daysCount[this.isLeapYear(year) ? 1 : 0][month]
if (day > daysCount) {
day = daysCount
date.setDate(day)
date.setMonth(month)
} else {
date.setMonth(month)
date.setDate(day)
}