From 8e23e55cc8ac719616699f60b4ae7c3b6a7552a5 Mon Sep 17 00:00:00 2001 From: gahusb Date: Mon, 16 Mar 2026 02:19:34 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20lunar-calendar=20=E2=86=92=20solarlunar?= =?UTF-8?q?=20=ED=8C=A8=ED=82=A4=EC=A7=80=EB=A1=9C=20=EA=B5=90=EC=B2=B4=20?= =?UTF-8?q?(=EB=B9=8C=EB=93=9C=20=EC=97=90=EB=9F=AC=20=EC=88=98=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- lib/lunar-utils.ts | 48 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/lib/lunar-utils.ts b/lib/lunar-utils.ts index ee9ce51..c52efd1 100644 --- a/lib/lunar-utils.ts +++ b/lib/lunar-utils.ts @@ -1,7 +1,11 @@ /** * 음력-양력 변환 유틸리티 + * solarlunar 패키지 사용 (https://www.npmjs.com/package/solarlunar) */ +// eslint-disable-next-line @typescript-eslint/no-require-imports +const solarlunar = require('solarlunar'); + interface LunarDate { year: number; month: number; @@ -17,10 +21,6 @@ interface SolarDate { /** * 음력을 양력으로 변환 - * @param lunarYear 음력 년 - * @param lunarMonth 음력 월 - * @param lunarDay 음력 일 - * @param isLeapMonth 윤달 여부 */ export function lunarToSolar( lunarYear: number, @@ -29,30 +29,20 @@ export function lunarToSolar( isLeapMonth: boolean = false ): SolarDate { try { - const lunar = require('lunar-calendar'); - const result = lunar.lunarToSolar(lunarYear, lunarMonth, lunarDay, isLeapMonth); - + const result = solarlunar.lunar2solar(lunarYear, lunarMonth, lunarDay, isLeapMonth); return { - year: result.year, - month: result.month, - day: result.day + year: result.cYear, + month: result.cMonth, + day: result.cDay, }; } catch (error) { console.error('음력 변환 오류:', error); - // 변환 실패시 입력값 그대로 반환 - return { - year: lunarYear, - month: lunarMonth, - day: lunarDay - }; + return { year: lunarYear, month: lunarMonth, day: lunarDay }; } } /** * 양력을 음력으로 변환 - * @param solarYear 양력 년 - * @param solarMonth 양력 월 - * @param solarDay 양력 일 */ export function solarToLunar( solarYear: number, @@ -60,24 +50,16 @@ export function solarToLunar( solarDay: number ): LunarDate { try { - const lunar = require('lunar-calendar'); - const result = lunar.solarToLunar(solarYear, solarMonth, solarDay); - + const result = solarlunar.solar2lunar(solarYear, solarMonth, solarDay); return { - year: result.year, - month: result.month, - day: result.day, - isLeap: result.isLeap || false + year: result.lYear, + month: result.lMonth, + day: result.lDay, + isLeap: result.isLeap, }; } catch (error) { console.error('양력 변환 오류:', error); - // 변환 실패시 입력값 그대로 반환 - return { - year: solarYear, - month: solarMonth, - day: solarDay, - isLeap: false - }; + return { year: solarYear, month: solarMonth, day: solarDay, isLeap: false }; } }