fix: 修复农历日期显示错误

- 修复 getFriendlyDateDescription 函数错误地将公历月/日当作农历参数传入的问题
- 正确使用 getLunarFromSolar 将公历日期转换为农历显示

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ddshi 2026-02-28 11:16:10 +08:00
parent 183c88a6ac
commit 7dd8d15c28

View File

@ -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}`;