fix: 달이 안 보일 때 이유를 붙여 말하기(삭·일찍 짐·늦게 뜸·흐림), 달 포스트 설명글을 본문 판정에 맞추기

This commit is contained in:
minaChoi committed 2026-10-12 09:26:50 +09:00
1 parent ef57a47e29
commit f4fe3e965c
6 files changed
+25 -13

No files matched your search

+8 -5
View File
@@ -102,6 +102,7 @@ class MoonNight:
"""그날 밤(19시~다음 날 5시) 달. lit 는 빛나는 면의 비율(모양), 밝기가 아니다."""
name: str
lit: float
waxing: bool # 삭 → 보름 사이 (해 진 뒤 서쪽 하늘에 있다가 지는 쪽)
rise_at: Optional[datetime] # 밤 사이에 뜨면 그 시각 (저녁부터 떠 있으면 None)
set_at: Optional[datetime] # 밤 사이에 지면 그 시각 (새벽까지 떠 있으면 None)
up_hours: tuple[int, ...] # 달이 떠 있는 시각 (19~28, 24 이상은 다음 날)
@@ -124,7 +125,7 @@ def night(day: date, lat: float, lon: float) -> MoonNight:
ups.add(int((at - start).total_seconds() // 3600))
prev = up
at += _STEP
return MoonNight(name=phase_name(mid), lit=illumination(mid), rise_at=rise_at, set_at=set_at, up_hours=tuple(sorted(ups)))
return MoonNight(name=phase_name(mid), lit=illumination(mid), waxing=_fraction(mid) < 0.5, rise_at=rise_at, set_at=set_at, up_hours=tuple(sorted(ups)))
def up_ratio(m: MoonNight, hours: range) -> float:
@@ -133,13 +134,15 @@ def up_ratio(m: MoonNight, hours: range) -> float:
def view_line(m: MoonNight, cloudy: Optional[float]) -> str:
"""오늘 밤 달이 잘 보이는지 한 마디. cloudy 는 달이 떠 있는 동안 흐린 정도 0~1 (모르면 None)."""
if m.lit < 0.03 or not m.up_hours:
return "달이 안 보여요"
"""오늘 밤 달이 잘 보이는지 한 마디. 안 보이면 왜인지까지. cloudy 는 달이 떠 있는 동안 흐린 정도 0~1 (모르면 None)."""
if m.lit < 0.03:
return "해와 같은 쪽에 있어 안 보여요"
if not m.up_hours:
return "해 진 뒤 곧 져서 밤엔 안 보여요" if m.waxing else "새벽 늦게 떠서 밤엔 안 보여요"
if m.rise_at is not None and m.rise_at.hour not in range(19, 22):
return f"{_clock(m.rise_at)}에 떠요"
if cloudy is not None and cloudy >= 0.6:
return "구름에 가려요"
return "흐려서 구름에 가려요"
if cloudy is not None and cloudy >= 0.3:
return "구름 사이로 보여요"
if m.set_at is not None: