fix: 修复农历日期显示错误
- 修复 getFriendlyDateDescription 函数错误地将公历月/日当作农历参数传入的问题 - 正确使用 getLunarFromSolar 将公历日期转换为农历显示 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
183c88a6ac
commit
7dd8d15c28
@ -1,4 +1,5 @@
|
|||||||
import { Lunar } from 'lunar-javascript';
|
import { Lunar } from 'lunar-javascript';
|
||||||
|
import { getLunarFromSolar } from './lunar';
|
||||||
|
|
||||||
export interface CountdownResult {
|
export interface CountdownResult {
|
||||||
days: number;
|
days: number;
|
||||||
@ -267,12 +268,9 @@ export function getFriendlyDateDescription(
|
|||||||
const day = targetDate.getDate();
|
const day = targetDate.getDate();
|
||||||
|
|
||||||
if (isLunar) {
|
if (isLunar) {
|
||||||
// 显示农历
|
// 显示农历:使用 getLunarFromSolar 将公历日期正确转换为农历
|
||||||
const result = safeCreateLunarDate(targetDate.getFullYear(), month, day);
|
const lunarInfo = getLunarFromSolar(targetDate);
|
||||||
if (result) {
|
return `${lunarInfo.monthInChinese}${lunarInfo.dayInChinese}`;
|
||||||
return `${result.lunar.getMonthInChinese()}月${result.lunar.getDayInChinese()}`;
|
|
||||||
}
|
|
||||||
return `${month}月${day}日`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${month}月${day}日`;
|
return `${month}月${day}日`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user