From 11a7e2a06cc01c9afb874af34c8c516c749c7c4f Mon Sep 17 00:00:00 2001 From: ddshi <8811906+ddshi@user.noreply.gitee.com> Date: Sat, 28 Feb 2026 11:35:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20getLunarFromSolar?= =?UTF-8?q?=20=E5=AF=BC=E5=87=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 lunar.ts 中添加 getLunarFromSolar 函数导出 - 移除 countdown.ts 中的重复定义 Co-Authored-By: Claude Opus 4.6 --- src/utils/countdown.ts | 12 ------------ src/utils/lunar.ts | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/utils/countdown.ts b/src/utils/countdown.ts index 6abfb9e..efe6207 100644 --- a/src/utils/countdown.ts +++ b/src/utils/countdown.ts @@ -286,15 +286,3 @@ export function getSolarFromLunar(lunarMonth: number, lunarDay: number, year?: n return new Date(solar.getYear(), solar.getMonth() - 1, solar.getDay()); } -/** - * 获取公历日期的农历日期 - */ -export function getLunarFromSolar(solarDate: Date): { month: number; day: number; monthInChinese: string; dayInChinese: string } { - const lunar = Lunar.fromYmd(solarDate.getFullYear(), solarDate.getMonth() + 1, solarDate.getDate()); - return { - month: lunar.getMonth(), - day: lunar.getDay(), - monthInChinese: lunar.getMonthInChinese(), - dayInChinese: lunar.getDayInChinese(), - }; -} diff --git a/src/utils/lunar.ts b/src/utils/lunar.ts index 4780718..513af31 100644 --- a/src/utils/lunar.ts +++ b/src/utils/lunar.ts @@ -137,6 +137,19 @@ export function getDayGanZhi(date: Date): string { } } +/** + * 获取公历日期的农历信息 + */ +export function getLunarFromSolar(solarDate: Date): { month: number; day: number; monthInChinese: string; dayInChinese: string } { + const lunar = Lunar.fromYmd(solarDate.getFullYear(), solarDate.getMonth() + 1, solarDate.getDate()); + return { + month: lunar.getMonth(), + day: lunar.getDay(), + monthInChinese: lunar.getMonthInChinese(), + dayInChinese: lunar.getDayInChinese(), + }; +} + /** * 判断是否为农历节日 */