Skip to content

Commit 6b72bde

Browse files
committed
to_lunar_date: Raise ValueError if unexpected last_day
1 parent 570aea1 commit 6b72bde

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pythainlp/util/thai_lunar_date.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,14 @@ def to_lunar_date(input_date: date) -> str:
407407
days_in_month = _DAYS_355
408408
elif last_day == 384:
409409
days_in_month = _DAYS_384
410+
else:
411+
raise ValueError(
412+
f"Unexpected last_day value: {last_day!r}. "
413+
"Expected 354, 355, or 384."
414+
)
410415

411416
days_of_year = day_from_one
417+
th_m = 0
412418
for j, days in enumerate(days_in_month, start=1):
413419
th_m = j
414420
if 0 < days_of_year <= days:

0 commit comments

Comments
 (0)