Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Laos holidays #1483

Merged
merged 19 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Available Countries
.. _ISO 639-1 code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _ISO 639-2 code: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

We currently support 134 country codes. The standard way to refer to a country
We currently support 135 country codes. The standard way to refer to a country
is by using its `ISO 3166-1 alpha-2 code`_, the same used for domain names, and
for a subdivision its `ISO 3166-2 code`_. Some of the countries support more
than one language for holiday names output.
Expand Down Expand Up @@ -417,6 +417,10 @@ The list of supported countries, their subdivisions and supported languages
- KG
-
-
* - Laos
- LA
-
- en_US, **lo**, th
* - Latvia
- LV
-
Expand Down
185 changes: 135 additions & 50 deletions holidays/calendars/thai.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ def _get_start_date(self, year: int) -> Optional[date]:

while iter_start_year < year:
if iter_start_year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = 384
delta_days = +384
elif iter_start_year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 355
delta_days = +355
else:
delta_days = 354
delta_days = +354
iter_start_date += td(days=delta_days)
iter_start_year += 1
return iter_start_date
Expand All @@ -242,7 +242,7 @@ def makha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Magha Puja", "Makha Buxha" and "Meak Bochea".
This concides with the 15th Waxing Day of Month 3
This coincides with the 15th Waxing Day of Month 3
in Thai Lunar Calendar, or Month 4 in Athikamat years.

KHMER_CALENDAR will always use Month 3 regardless of year type.
Expand Down Expand Up @@ -285,9 +285,8 @@ def visakha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
Calculate the estimated Gregorian date of Visakha Bucha.
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Vesak" and "Buddha Day". This concides with
the 15th Waxing Day of Month 6 in Thai Lunar Calendar,
or Month 7 in Athikamat years.
Also known as "Vesak" and "Buddha Day". This coincides with
the 15th Waxing Day of Month 6 in Thai Lunar Calendar, or Month 7 in Athikamat years.

KHMER_CALENDAR will always use Month 6 regardless of year type.

Expand Down Expand Up @@ -330,7 +329,7 @@ def preah_neangkoal_date(self, year: int) -> Optional[date]:
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Cambodian Royal Ploughing Ceremony". This always
concides with the 4th Waning Day of Month 6 in Khmer Lunar Calendar.
coincides with the 4th Waning Day of Month 6 in Khmer Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 15th Waxing Day of Month 6
Expand Down Expand Up @@ -358,9 +357,8 @@ def atthami_bucha_date(self, year: int, calendar=None) -> Optional[date]:
Calculate the estimated Gregorian date of Atthami Bucha.
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Buddha's Cremation Day". This concides with
the 8th Waning Day of Month 6 in Thai Lunar Calendar,
or Month 7 in Athikamat years.
Also known as "Buddha's Cremation Day". This coincides with
the 8th Waning Day of Month 6 in Thai Lunar Calendar, or Month 7 in Athikamat years.

KHMER_CALENDAR will always use Month 6 regardless of year type.

Expand Down Expand Up @@ -398,16 +396,16 @@ def atthami_bucha_date(self, year: int, calendar=None) -> Optional[date]:
else +169
)

def asarnha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
def asarnha_bucha_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Asarnha Bucha.
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Asalha Puja". This concides with
Also known as "Asalha Puja". This coincides with
the 15th Waxing Day of Month 8 in Thai Lunar Calendar,
or Month 8.8 in Athikamat years.

KHMER_CALENDAR will always use Month 8 regardless of year type.
Lao Start of Buddhist Lent start on this day (1-day earlier than Thai and Khmer ones).

To calculate, we use use the following time delta:
- Athikamat: 15th Waxing Day of Month 8/8
Expand All @@ -426,34 +424,27 @@ def asarnha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
:return:
Estimated Gregorian date of Asarnha Bucha.
"""
calendar = calendar or self.__calendar
PPsyrius marked this conversation as resolved.
Show resolved Hide resolved
self.__verify_calendar(calendar)

start_date = self._get_start_date(year)
if not start_date:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN and not self.__is_khmer_calendar(
calendar
):
delta_days = 250
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = +250
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 221
delta_days = +221
else:
delta_days = 220
delta_days = +220
return start_date + td(days=delta_days)

def khao_phansa_date(self, year: int, calendar=None) -> Optional[date]:
def khao_phansa_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Khao Phansa.
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "(Start of) Buddhist Lent" and "Start of Vassa".
This concides with the 1st Waning Day of Month 8
This coincides with the 1st Waning Day of Month 8
in Thai Lunar Calendar, or Month 8.8 in Athikamat years.

KHMER_CALENDAR will always use Month 8 regardless of year type.

To calculate, we use use the following time delta:
- Athikamat: 1st Waning Day of Month 8.8
or 177[1-6] + 29[7] + 30[8] + 16[8.8] -1 = 251
Expand All @@ -472,21 +463,84 @@ def khao_phansa_date(self, year: int, calendar=None) -> Optional[date]:
:return:
Estimated Gregorian date of Khao Phansa.
"""
calendar = calendar or self.__calendar
self.__verify_calendar(calendar)
start_date = self._get_start_date(year)
if not start_date:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = +251
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = +222
else:
delta_days = +221
return start_date + td(days=delta_days)

def boun_haw_khao_padapdin_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Boun Haw Khao Padapdin.
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Boon Khao Padap Din".
This coincides with the 14th Waning Day of Month 9 in Thai Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 14th Waning Day of Month 9
or 236[1-8] + 30[8.8] + 29[9] -1 = 294
- Athikawan: 14th Waning Day of Month 9
or 236[1-8] + 1[7] + 29[9] -1 = 265
- Pakatimat: 14th Waning Day of Month 9
or 236[1-8] + 29[9] -1 = 264

:param year:
The Gregorian year.

:return:
Estimated Gregorian date of Boun Haw Khao Padapdin.
"""
start_date = self._get_start_date(year)
if not start_date:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = +294
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = +265
else:
delta_days = +264
return start_date + td(days=delta_days)

def boun_haw_khao_salark_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Boun Haw Khao Salark.
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Boon Khao Sak".
This coincides with the 15th Waxing Day of Month 10 in Thai Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 15th Waxing Day of Month 10
or 265[1-9] + 30[8.8] + 15[10] -1 = 309
- Athikawan: 15th Waxing Day of Month 10
or 265[1-9] + 1[7] + 15[10] -1 = 280
- Pakatimat: 15th Waxing Day of Month 10
or 265[1-9] + 15[10] -1 = 279

:param year:
The Gregorian year.

:return:
Estimated Gregorian date of Pchum Ben.
"""
start_date = self._get_start_date(year)
if not start_date:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN and not self.__is_khmer_calendar(
calendar
):
delta_days = 251
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = +309
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 222
delta_days = +280
else:
delta_days = 221
delta_days = +279
return start_date + td(days=delta_days)

def pchum_ben_date(self, year: int) -> Optional[date]:
Expand All @@ -495,8 +549,7 @@ def pchum_ben_date(self, year: int) -> Optional[date]:
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Prachum Bandar".
This concides with the 15th Waning Day of Month 10 in
Thai Lunar Calendar.
This coincides with the 15th Waning Day of Month 10 in Thai Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 15th Waning Day of Month 10
Expand All @@ -517,11 +570,11 @@ def pchum_ben_date(self, year: int) -> Optional[date]:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = 324
delta_days = +324
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 295
delta_days = +295
else:
delta_days = 294
delta_days = +294
return start_date + td(days=delta_days)

def ok_phansa_date(self, year: int) -> Optional[date]:
Expand All @@ -530,8 +583,7 @@ def ok_phansa_date(self, year: int) -> Optional[date]:
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "End of Buddhist Lent" and "End of Vassa".
This concides with the 15th Waxing Day of Month 11
in Thai Lunar Calendar.
This coincides with the 15th Waxing Day of Month 11 in Thai Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 15th Waxing Day of Month 11
Expand All @@ -552,11 +604,45 @@ def ok_phansa_date(self, year: int) -> Optional[date]:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = 339
delta_days = +339
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = +310
else:
delta_days = +309
return start_date + td(days=delta_days)

def boun_suang_heua_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Ok Boun Suang Huea.
If the Gregorian year input is invalid, this will outputs None instead.

Boun Suang Huea Nakhone Luang Prabang, also known as "Vientiane Boat Racing Festival".
This coincides with the 1st Waning Day of Month 11 in Thai Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 1st Waning Day of Month 11
or 295[1-10] + 30[8.8] + 16[11] -1 = 340
- Athikawan: 1st Waning Day of Month 11
or 295[1-10] + 1[7] + 16[11] -1 = 311
- Pakatimat: 1st Waning Day of Month 11
or 295[1-10] + 16[11] -1 = 310

:param year:
The Gregorian year.

:return:
Estimated Gregorian date of Boun Suang Huea.
"""
start_date = self._get_start_date(year)
if not start_date:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = +340
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 310
delta_days = +311
else:
delta_days = 309
delta_days = +310
return start_date + td(days=delta_days)

def loy_krathong_date(self, year: int) -> Optional[date]:
Expand All @@ -565,8 +651,7 @@ def loy_krathong_date(self, year: int) -> Optional[date]:
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Boun That Louang" and "Bon Om Touk".
This concides with the 15th Waxing Day of Month 12
in Thai Lunar Calendar.
This coincides with the 15th Waxing Day of Month 12 in Thai Lunar Calendar.

To calculate, we use use the following time delta:
- Athikamat: 15th Waxing Day of Month 12
Expand All @@ -587,9 +672,9 @@ def loy_krathong_date(self, year: int) -> Optional[date]:
return None

if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = 368
delta_days = +368
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 339
delta_days = +339
else:
delta_days = 338
delta_days = +338
return start_date + td(days=delta_days)
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from .kazakhstan import Kazakhstan, KZ, KAZ
from .kenya import Kenya, KE, KEN
from .kyrgyzstan import Kyrgyzstan, KG, KGZ
from .laos import Laos, LA, LAO
from .latvia import Latvia, LV, LVA
from .lesotho import Lesotho, LS, LSO
from .liechtenstein import Liechtenstein, LI, LIE
Expand Down
Loading