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 12 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
139 changes: 112 additions & 27 deletions holidays/calendars/thai.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ def visakha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
If the Gregorian year input is invalid, this will outputs None instead.

Also known as "Vesak" and "Buddha Day". This concides with
PPsyrius marked this conversation as resolved.
Show resolved Hide resolved
the 15th Waxing Day of Month 6 in Thai Lunar Calendar,
or Month 7 in Athikamat years.
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 @@ -359,8 +358,7 @@ def atthami_bucha_date(self, year: int, calendar=None) -> Optional[date]:
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.
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,7 +396,7 @@ 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.
Expand All @@ -407,7 +405,7 @@ def asarnha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
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,24 +424,19 @@ 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
):
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
delta_days = 250
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 221
else:
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.
Expand All @@ -452,8 +445,6 @@ def khao_phansa_date(self, year: int, calendar=None) -> Optional[date]:
This concides 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,31 +463,93 @@ 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 and not self.__is_khmer_calendar(
calendar
):
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 concides 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
PPsyrius marked this conversation as resolved.
Show resolved Hide resolved
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 concides 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:
delta_days = 309
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
delta_days = 280
else:
delta_days = 279
return start_date + td(days=delta_days)

def pchum_ben_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Pchum Ben.
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 concides 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 Down Expand Up @@ -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 concides 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 Down Expand Up @@ -559,14 +611,47 @@ def ok_phansa_date(self, year: int) -> Optional[date]:
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 concides 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 = 311
else:
delta_days = 310
return start_date + td(days=delta_days)

def loy_krathong_date(self, year: int) -> Optional[date]:
"""
Calculate the estimated Gregorian date of Loy Krathong.
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 concides 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 Down
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