Skip to content

Commit 43a450d

Browse files
committed
Use f-string
1 parent 5a5285f commit 43a450d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

pythainlp/util/thai_lunar_date.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,9 @@ def th_zodiac(year: int, output_type: int = 1) -> Union[str, int]:
324324
date(2442, 12, 2),
325325
date(2452, 12, 11),
326326
]
327-
_DAYS_YEAR_354 = [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30]
328-
_DAYS_YEAR_355 = [29, 30, 29, 30, 29, 30, 30, 30, 29, 30, 29, 30, 29, 30]
329-
_DAYS_YEAR_384 = [29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30]
327+
_DAYS_354 = [29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30, 29, 30]
328+
_DAYS_355 = [29, 30, 29, 30, 29, 30, 30, 30, 29, 30, 29, 30, 29, 30]
329+
_DAYS_384 = [29, 30, 29, 30, 29, 30, 29, 30, 30, 29, 30, 29, 30, 29, 30]
330330

331331

332332
def to_lunar_date(input_date: date) -> str:
@@ -360,11 +360,11 @@ def to_lunar_date(input_date: date) -> str:
360360
last_day = last_day_in_year(input_date.year)
361361

362362
if last_day == 354:
363-
days_in_month = _DAYS_YEAR_354
363+
days_in_month = _DAYS_354
364364
elif last_day == 355:
365-
days_in_month = _DAYS_YEAR_355
365+
days_in_month = _DAYS_355
366366
elif last_day == 384:
367-
days_in_month = _DAYS_YEAR_384
367+
days_in_month = _DAYS_384
368368

369369
days_of_year = day_from_one
370370
for j, days in enumerate(days_in_month, start=1):
@@ -384,11 +384,11 @@ def to_lunar_date(input_date: date) -> str:
384384
th_m = th_m - 1
385385

386386
if days_of_year > 15:
387-
th_s = "แรม "
387+
th_s = "แรม"
388388
days_of_year = days_of_year - 15
389389
else:
390-
th_s = "ขึ้น "
390+
th_s = "ขึ้น"
391391

392-
thai_lunar_date = th_s + str(days_of_year) + " ค่ำ เดือน " + str(th_m)
392+
thai_lunar_date = f"{th_s} {days_of_year} ค่ำ เดือน {th_m}"
393393

394394
return thai_lunar_date

0 commit comments

Comments
 (0)