feat(saju-lab): lunar.py — 음력↔양력 변환 (sxtwl)
This commit is contained in:
23
saju-lab/app/calculator/lunar.py
Normal file
23
saju-lab/app/calculator/lunar.py
Normal 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(),
|
||||
)
|
||||
Reference in New Issue
Block a user