From 7dd8d15c285495a223306499309af0d2d75d0f0c Mon Sep 17 00:00:00 2001 From: ddshi <8811906+ddshi@user.noreply.gitee.com> Date: Sat, 28 Feb 2026 11:16:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=86=9C=E5=8E=86?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=98=BE=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 getFriendlyDateDescription 函数错误地将公历月/日当作农历参数传入的问题 - 正确使用 getLunarFromSolar 将公历日期转换为农历显示 Co-Authored-By: Claude Opus 4.6 --- src/utils/countdown.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/utils/countdown.ts b/src/utils/countdown.ts index f7c6ae6..6abfb9e 100644 --- a/src/utils/countdown.ts +++ b/src/utils/countdown.ts @@ -1,4 +1,5 @@ import { Lunar } from 'lunar-javascript'; +import { getLunarFromSolar } from './lunar'; export interface CountdownResult { days: number; @@ -267,12 +268,9 @@ export function getFriendlyDateDescription( const day = targetDate.getDate(); if (isLunar) { - // 显示农历 - const result = safeCreateLunarDate(targetDate.getFullYear(), month, day); - if (result) { - return `${result.lunar.getMonthInChinese()}月${result.lunar.getDayInChinese()}`; - } - return `${month}月${day}日`; + // 显示农历:使用 getLunarFromSolar 将公历日期正确转换为农历 + const lunarInfo = getLunarFromSolar(targetDate); + return `${lunarInfo.monthInChinese}${lunarInfo.dayInChinese}`; } return `${month}月${day}日`;