fix: lunar-calendar → solarlunar 패키지로 교체 (빌드 에러 수정)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-16 02:19:34 +09:00
parent a95715ec6b
commit 8e23e55cc8

View File

@@ -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 { interface LunarDate {
year: number; year: number;
month: number; month: number;
@@ -17,10 +21,6 @@ interface SolarDate {
/** /**
* 음력을 양력으로 변환 * 음력을 양력으로 변환
* @param lunarYear 음력 년
* @param lunarMonth 음력 월
* @param lunarDay 음력 일
* @param isLeapMonth 윤달 여부
*/ */
export function lunarToSolar( export function lunarToSolar(
lunarYear: number, lunarYear: number,
@@ -29,30 +29,20 @@ export function lunarToSolar(
isLeapMonth: boolean = false isLeapMonth: boolean = false
): SolarDate { ): SolarDate {
try { try {
const lunar = require('lunar-calendar'); const result = solarlunar.lunar2solar(lunarYear, lunarMonth, lunarDay, isLeapMonth);
const result = lunar.lunarToSolar(lunarYear, lunarMonth, lunarDay, isLeapMonth);
return { return {
year: result.year, year: result.cYear,
month: result.month, month: result.cMonth,
day: result.day day: result.cDay,
}; };
} catch (error) { } catch (error) {
console.error('음력 변환 오류:', 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( export function solarToLunar(
solarYear: number, solarYear: number,
@@ -60,24 +50,16 @@ export function solarToLunar(
solarDay: number solarDay: number
): LunarDate { ): LunarDate {
try { try {
const lunar = require('lunar-calendar'); const result = solarlunar.solar2lunar(solarYear, solarMonth, solarDay);
const result = lunar.solarToLunar(solarYear, solarMonth, solarDay);
return { return {
year: result.year, year: result.lYear,
month: result.month, month: result.lMonth,
day: result.day, day: result.lDay,
isLeap: result.isLeap || false isLeap: result.isLeap,
}; };
} catch (error) { } catch (error) {
console.error('양력 변환 오류:', error); console.error('양력 변환 오류:', error);
// 변환 실패시 입력값 그대로 반환 return { year: solarYear, month: solarMonth, day: solarDay, isLeap: false };
return {
year: solarYear,
month: solarMonth,
day: solarDay,
isLeap: false
};
} }
} }