Skip to content

Commit

Permalink
Refactor Thai calendar (#1628)
Browse files Browse the repository at this point in the history
  • Loading branch information
KJhellico authored Jan 5, 2024
1 parent 58cd972 commit 0c1b6b0
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions holidays/calendars/thai.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,14 @@ def _get_start_date(self, year: int) -> Optional[date]:
if year < _ThaiLunisolar.START_YEAR or year > _ThaiLunisolar.END_YEAR:
return None

iter_start_date = _ThaiLunisolar.START_DATE
iter_start_year = _ThaiLunisolar.START_YEAR

while iter_start_year < year:
if iter_start_year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = +384
elif iter_start_year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = +355
else:
delta_days = +354
iter_start_date += td(days=delta_days)
iter_start_year += 1
return iter_start_date
delta_days = 354 * (year - _ThaiLunisolar.START_YEAR)
for iter_year in range(_ThaiLunisolar.START_YEAR, year):
if iter_year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days += 30
elif iter_year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days += 1

return _ThaiLunisolar.START_DATE + td(days=delta_days)

def makha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
"""
Expand Down

0 comments on commit 0c1b6b0

Please sign in to comment.