feat(saju-lab): lunar.py — 음력↔양력 변환 (sxtwl)

This commit is contained in:
2026-05-25 19:39:06 +09:00
parent 95243a7f1f
commit f91a74237b
2 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
"""음력↔양력 변환 — sxtwl 기반."""
import sxtwl
def solar_to_lunar(year: int, month: int, day: int) -> dict:
"""양력 → 음력 변환. {'year', 'month', 'day', 'is_leap'} 반환."""
day_obj = sxtwl.fromSolar(year, month, day)
return {
"year": day_obj.getLunarYear(),
"month": day_obj.getLunarMonth(),
"day": day_obj.getLunarDay(),
"is_leap": bool(day_obj.isLunarLeap()),
}
def lunar_to_solar(year: int, month: int, day: int, is_leap: bool = False) -> tuple[int, int, int]:
"""음력 → 양력 변환. (year, month, day) tuple 반환."""
day_obj = sxtwl.fromLunar(year, month, day, is_leap)
return (
day_obj.getSolarYear(),
day_obj.getSolarMonth(),
day_obj.getSolarDay(),
)