This commit is contained in:
freedakgmail
2025-12-22 00:38:20 +08:00
parent 5a604e89f9
commit c2b890994d
9 changed files with 507 additions and 240 deletions
+17 -1
View File
@@ -290,7 +290,23 @@ export function isInCurrentMonth(dateStr: string, isLunar: boolean = false): { d
originalLunar.isLeap
)
if (!thisYearSolar) return null
if (!thisYearSolar) {
// 如果转换失败,尝试用明年的日期
const nextYearSolar = lunar2solar(
currentYear + 1,
originalLunar.lunarMonth,
originalLunar.lunarDay,
originalLunar.isLeap
)
if (nextYearSolar) {
const nextYearMonth = nextYearSolar.getMonth() + 1
const nextYearDay = nextYearSolar.getDate()
if (nextYearMonth === currentMonth) {
return { day: nextYearDay, month: nextYearMonth }
}
}
return null
}
const thisYearMonth = thisYearSolar.getMonth() + 1
const thisYearDay = thisYearSolar.getDate()