export function setCompareRegistrationTimeText(startDate, endDate) {
const date = new Date(startDate)
const year = date.getFullYear()
const month = date.getMonth() + 1
const dd = date.getDate()
const nowDate = new Date(endDate)
const nowYear = nowDate.getFullYear()
const nowMonth = nowDate.getMonth() + 1
const nowDd = nowDate.getDate()
const restDd =
nowDd - dd < 0 ? lastDay(nowMonth - 1, year) - dd + nowDd : nowDd - dd
const restMonth =
nowMonth - month < 0 ? 12 + nowMonth - month : nowMonth - month
const restYear = nowYear - year
let resultMonth = restMonth
let resultYear = restYear
if (nowDd < dd) {
resultMonth = restMonth - 1 < 0 ? restMonth - 1 + 12 : restMonth - 1
}
if (nowMonth < month || (nowDd < dd && nowMonth === month)) {
resultYear = restYear - 1
}
let str = {
year: resultYear,
month: resultMonth,
day: restDd
}
return str
},
export function lastDay(mo, year) {
if (mo === 4 || mo === 6 || mo === 9 || mo === 11) {
return 30
}
else if (mo === 2) {
if (isLeapYear(year)) {
return 29
} else {
return 28
}
}
else {
return 31
}
},
export function isLeapYear(Year) {
return (Year % 4 === 0 && Year % 100 !== 0) || Year % 400 === 0
},