isDateAfterNaturalMonth(date) {
const currentDate = new Date();
const currentMonth = currentDate.getMonth();
const currentYear = currentDate.getFullYear();
const targetDate = new Date(date);
const targetMonth = targetDate.getMonth();
const targetYear = targetDate.getFullYear();
// 判断年份是否相同
if (currentYear === targetYear) {
// 判断月份是否相同
if (currentMonth === targetMonth) {
return false; // 当前日期和目标日期在同一个自然月内
} else if (currentMonth < targetMonth) {
return false; // 当前月份在目标月份之前,不超过自然月
} else {
return true; // 当前月份在目标月份之后,超过自然月
}
} else if (currentYear < targetYear) {
return false; // 当前年份在目标年份之前,不超过自然月
} else {
return true; // 当前年份在目标年份之后,超过自然月
}
},
判断推荐日期是否在当前月内
最新推荐文章于 2024-07-21 16:09:52 发布