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

Refactor Lao New Year holidays #1962

Merged
merged 4 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
99 changes: 46 additions & 53 deletions holidays/countries/laos.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@

from gettext import gettext as tr

from holidays.calendars.gregorian import JAN, MAR, APR, MAY, JUL, OCT, DEC
from holidays.calendars.gregorian import JAN, APR, JUL
from holidays.calendars.thai import KHMER_CALENDAR
from holidays.constants import BANK, PUBLIC, SCHOOL, WORKDAY
from holidays.groups import InternationalHolidays, ThaiCalendarHolidays, StaticHolidays
from holidays.observed_holiday_base import (
ObservedHolidayBase,
THU_FRI_TO_NEXT_MON,
THU_TO_NEXT_TUE,
FRI_TO_NEXT_TUE,
SAT_TO_NEXT_TUE,
WED_THU_TO_NEXT_MON,
FRI_SAT_TO_NEXT_WED,
SAT_SUN_TO_NEXT_MON,
SAT_SUN_TO_NEXT_WED,
SAT_SUN_TO_NEXT_THU,
)


Expand All @@ -40,7 +44,8 @@ class Laos(ObservedHolidayBase, InternationalHolidays, StaticHolidays, ThaiCalen
https://asean.org/wp-content/uploads/2022/12/ASEAN-Public-Holidays-2023.pdf
https://www.timeanddate.com/holidays/laos/
https://www.bcel.com.la/bcel/bcel-calendar.html?y=2022
https://www.bcel.com.la/bcel/bcel-calendar.html?year=2023
https://www.bcel.com.la/bcel/bcel-calendar.html?y=2023
https://www.bcel.com.la/bcel/bcel-calendar.html?y=2024
http://www.lsx.com.la/cal/getStockCalendar.do?lang=lo (from 2011 onwards)

!!! If Public Holiday falls on weekends, (in lieu) on workday !!!
Expand All @@ -51,6 +56,8 @@ class Laos(ObservedHolidayBase, InternationalHolidays, StaticHolidays, ThaiCalen
- Saturdays and Sundays shall be restdays each week.
- In-Lieu holidays shall be given if it fall on the weekends.

Although in-lieus has been de facto observed since at least 2012.

Limitations:

- Laotian holidays only works from 1976 onwards, and are only 100% accurate from 2018 onwards.
Expand All @@ -76,7 +83,7 @@ def __init__(self, *args, **kwargs):
ThaiCalendarHolidays.__init__(self, KHMER_CALENDAR)
StaticHolidays.__init__(self, cls=LaosStaticHolidays)
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_MON)
kwargs.setdefault("observed_since", 2018)
kwargs.setdefault("observed_since", 2012)
super().__init__(*args, **kwargs)

def _populate_bank_holidays(self):
Expand Down Expand Up @@ -126,27 +133,51 @@ def _populate_public_holidays(self):
# ວັນແມ່ຍິງສາກົນ
# Status: In-Use.
# Only acts as day off for Women.
# No in-lieus are observed in 2014.

# International Women's Rights Day.
self._add_observed(self._add_womens_day(tr("ວັນແມ່ຍິງສາກົນ")))
womens_day = self._add_womens_day(tr("ວັນແມ່ຍິງສາກົນ"))
if self._year != 2014:
self._add_observed(womens_day)

# ບຸນປີໃໝ່ລາວ
# Status: In-Use.
# Celebrated for 3 days from 14-16 April annualy.
# Observed dates prior to 2018 are assigned manually.
# - CASE 1: THU-FRI-SAT -> in lieu on MON.
# - CASE 2: FRI-SAT-SUN -> in lieu on MON-TUE.
# - CASE 3: SAT-SUN-MON -> in lieu on TUE-WED.
# - CASE 4: SUN-MON-TUE -> in lieu on WED.

# Lao New Year's Day.
name = tr("ບຸນປີໃໝ່ລາວ")
dt = self._add_holiday_apr_14(name)
self._add_holiday_apr_15(name)
self._add_holiday_apr_16(name)

self._add_observed(dt, rule=THU_FRI_TO_NEXT_MON + SAT_TO_NEXT_TUE)
self._add_observed(dt, rule=FRI_TO_NEXT_TUE + SAT_SUN_TO_NEXT_WED)
songkran_years_apr_13_15 = {2012, 2017}
songkran_years_apr_13_16 = {2016, 2020, 2024}
if self._year in songkran_years_apr_13_16:
dt = self._add_holiday_apr_13(name)
self._add_holiday_apr_14(name)
self._add_holiday_apr_15(name)
self._add_holiday_apr_16(name)

# - CASE 1: WED-THU-FRI-SAT -> in lieu on MON.
# - CASE 2: THU-FRI-SAT-SUN -> in lieu on MON-TUE.
# - CASE 3: FRI-SAT-SUN-MON -> in lieu on TUE-WED.
# - CASE 4: SAT-SUN-MON-TUE -> in lieu on WED-THU.
# - CASE 5: SUN-MON-TUE-WED -> in lieu on THU.
self._add_observed(dt, rule=WED_THU_TO_NEXT_MON + FRI_SAT_TO_NEXT_WED)
self._add_observed(dt, rule=THU_TO_NEXT_TUE + FRI_TO_NEXT_TUE + SAT_SUN_TO_NEXT_THU)
else:
if self._year in songkran_years_apr_13_15:
dt = self._add_holiday_apr_13(name)
self._add_holiday_apr_14(name)
self._add_holiday_apr_15(name)
else:
dt = self._add_holiday_apr_14(name)
self._add_holiday_apr_15(name)
self._add_holiday_apr_16(name)

# - CASE 1: THU-FRI-SAT -> in lieu on MON.
# - CASE 2: FRI-SAT-SUN -> in lieu on MON-TUE.
# - CASE 3: SAT-SUN-MON -> in lieu on TUE-WED.
# - CASE 4: SUN-MON-TUE -> in lieu on WED.
self._add_observed(dt, rule=THU_FRI_TO_NEXT_MON + SAT_SUN_TO_NEXT_WED)
self._add_observed(dt, rule=FRI_TO_NEXT_TUE + SAT_TO_NEXT_TUE)
PPsyrius marked this conversation as resolved.
Show resolved Hide resolved

# ວັນກຳມະກອນສາກົນ
# Status: In-Use.
Expand Down Expand Up @@ -377,9 +408,6 @@ class LaosStaticHolidays:
# Special Bank Holiday.
special_bank_day_off = tr("ມື້ປິດການໃຫ້ບໍລິການຂອງທະນາຄານຕົວແທນ")

# New Year's Day.
new_year_day = tr("ວັນປີໃໝ່ສາກົນ")

# International Women's Rights Day.
international_womens_rights_day = tr("ວັນແມ່ຍິງສາກົນ")

Expand All @@ -389,55 +417,20 @@ class LaosStaticHolidays:
# Lao New Year's Day (Special).
lao_new_year_special = tr("ພັກບຸນປີໃໝ່ລາວ")

# International Labor Day.
international_labor_day = tr("ວັນກຳມະກອນສາກົນ")

# Establishment Day of the Lao Women's Union.
lao_womens_union = tr("ວັນສ້າງຕັ້ງສະຫະພັນແມ່ຍິງລາວ")

# Establishment Day of the BOL.
establishment_day_of_bol = tr("ວັນສ້າງຕັ້ງທະນາຄານແຫ່ງ ສປປ ລາວ")

# Lao National Day.
lao_national_day = tr("ວັນຊາດ")

special_bank_holidays = {
2015: (JAN, 2, special_bank_day_off),
}

special_bank_holidays_observed = {
2017: (OCT, 9, establishment_day_of_bol),
}

special_public_holidays = {
2015: (APR, 17, lao_new_year_special),
2016: (
(APR, 13, lao_new_year_special),
(APR, 18, lao_new_year_special),
),
2020: (
(APR, 13, lao_new_year_special),
(APR, 17, lao_new_year_special),
),
}

special_public_holidays_observed = {
2011: (APR, 13, lao_new_year),
2012: (
(JAN, 2, new_year_day),
(APR, 13, lao_new_year),
(APR, 17, lao_new_year),
(DEC, 3, lao_national_day),
),
2013: (APR, 17, lao_new_year),
2015: (MAR, 9, international_womens_rights_day),
2016: (MAY, 2, international_labor_day),
2017: (
(JAN, 2, new_year_day),
(APR, 13, lao_new_year),
(APR, 17, lao_new_year),
(DEC, 4, lao_national_day),
),
2020: (APR, 17, lao_new_year),
}

special_workday_holidays_observed = {
Expand Down
4 changes: 4 additions & 0 deletions holidays/observed_holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __add__(self, other):
THU_TO_PREV_MON = ObservedRule({THU: -3})
THU_TO_PREV_WED = ObservedRule({THU: -1})
THU_TO_NEXT_MON = ObservedRule({THU: +4})
THU_TO_NEXT_TUE = ObservedRule({THU: +5})
THU_TO_NEXT_FRI = ObservedRule({THU: +1})

FRI_TO_PREV_WED = ObservedRule({FRI: -2})
Expand Down Expand Up @@ -79,20 +80,23 @@ def __add__(self, other):
TUE_WED_TO_PREV_MON = ObservedRule({TUE: -1, WED: -2})
TUE_WED_THU_TO_PREV_MON = ObservedRule({TUE: -1, WED: -2, THU: -3})

WED_THU_TO_NEXT_MON = ObservedRule({WED: +5, THU: +4})
WED_THU_TO_NEXT_FRI = ObservedRule({WED: +2, THU: +1})

THU_FRI_TO_NEXT_MON = ObservedRule({THU: +4, FRI: +3})
THU_FRI_TO_NEXT_WORKDAY = ObservedRule({THU: +7, FRI: +7})
THU_FRI_SUN_TO_NEXT_MON = ObservedRule({THU: +4, FRI: +3, SUN: +1})

FRI_SAT_TO_NEXT_WORKDAY = ObservedRule({FRI: +7, SAT: +7})
FRI_SAT_TO_NEXT_WED = ObservedRule({FRI: +5, SAT: +4})
FRI_SUN_TO_NEXT_MON = ObservedRule({FRI: +3, SUN: +1})
FRI_SUN_TO_NEXT_SAT_MON = ObservedRule({FRI: +1, SUN: +1})

SAT_SUN_TO_PREV_FRI = ObservedRule({SAT: -1, SUN: -2})
SAT_SUN_TO_NEXT_MON = ObservedRule({SAT: +2, SUN: +1})
SAT_SUN_TO_NEXT_TUE = ObservedRule({SAT: +3, SUN: +2})
SAT_SUN_TO_NEXT_WED = ObservedRule({SAT: +4, SUN: +3})
SAT_SUN_TO_NEXT_THU = ObservedRule({SAT: +5, SUN: +4})
SAT_SUN_TO_NEXT_MON_TUE = ObservedRule({SAT: +2, SUN: +2})
SAT_SUN_TO_NEXT_WORKDAY = ObservedRule({SAT: +7, SUN: +7})

Expand Down
18 changes: 10 additions & 8 deletions snapshots/countries/LA_COMMON.json
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,10 @@
"2012-02-07": "Makha Bousa Festival",
"2012-03-08": "International Women's Rights Day",
"2012-03-22": "Establishment Day of the Lao People's Revolutionary Party",
"2012-04-13": "Lao New Year's Day (in lieu)",
"2012-04-13": "Lao New Year's Day",
"2012-04-14": "Lao New Year's Day; Lao People's Revolutionary Youth Union Day",
"2012-04-15": "Lao New Year's Day",
"2012-04-16": "Lao New Year's Day",
"2012-04-16": "Lao New Year's Day (in lieu)",
"2012-04-17": "Lao New Year's Day (in lieu)",
"2012-05-01": "International Labor Day",
"2012-05-05": "Visakha Bousa Festival",
Expand All @@ -1048,6 +1048,7 @@
"2012-09-15": "Boun Haw Khao Padapdin",
"2012-09-30": "Boun Haw Khao Salark",
"2012-10-07": "Establishment Day of the BOL; National Teacher Day",
"2012-10-08": "Establishment Day of the BOL (in lieu)",
"2012-10-12": "Indepedence Declaration Day",
"2012-10-30": "End of Buddhist Lent",
"2012-10-31": "Vientiane Boat Racing Festival",
Expand Down Expand Up @@ -1158,11 +1159,11 @@
"2016-02-22": "Makha Bousa Festival",
"2016-03-08": "International Women's Rights Day",
"2016-03-22": "Establishment Day of the Lao People's Revolutionary Party",
"2016-04-13": "Lao New Year's Day (Special)",
"2016-04-13": "Lao New Year's Day",
"2016-04-14": "Lao New Year's Day; Lao People's Revolutionary Youth Union Day",
"2016-04-15": "Lao New Year's Day",
"2016-04-16": "Lao New Year's Day",
"2016-04-18": "Lao New Year's Day (Special)",
"2016-04-18": "Lao New Year's Day (in lieu)",
"2016-05-01": "International Labor Day",
"2016-05-02": "International Labor Day (in lieu)",
"2016-05-20": "Visakha Bousa Festival",
Expand Down Expand Up @@ -1192,10 +1193,9 @@
"2017-02-11": "Makha Bousa Festival",
"2017-03-08": "International Women's Rights Day",
"2017-03-22": "Establishment Day of the Lao People's Revolutionary Party",
"2017-04-13": "Lao New Year's Day (in lieu)",
"2017-04-13": "Lao New Year's Day",
"2017-04-14": "Lao New Year's Day; Lao People's Revolutionary Youth Union Day",
"2017-04-15": "Lao New Year's Day",
"2017-04-16": "Lao New Year's Day",
"2017-04-17": "Lao New Year's Day (in lieu)",
"2017-05-01": "International Labor Day",
"2017-05-10": "Visakha Bousa Festival",
Expand Down Expand Up @@ -1293,11 +1293,11 @@
"2020-03-08": "International Women's Rights Day",
"2020-03-09": "International Women's Rights Day (in lieu)",
"2020-03-22": "Establishment Day of the Lao People's Revolutionary Party",
"2020-04-13": "Lao New Year's Day (Special)",
"2020-04-13": "Lao New Year's Day",
"2020-04-14": "Lao New Year's Day; Lao People's Revolutionary Youth Union Day",
"2020-04-15": "Lao New Year's Day",
"2020-04-16": "Lao New Year's Day",
"2020-04-17": "Lao New Year's Day (Special)",
"2020-04-17": "Lao New Year's Day (in lieu)",
"2020-05-01": "International Labor Day",
"2020-05-06": "Visakha Bousa Festival",
"2020-06-01": "International Children Day; National Arbor Day",
Expand Down Expand Up @@ -1423,10 +1423,12 @@
"2024-02-24": "Makha Bousa Festival",
"2024-03-08": "International Women's Rights Day",
"2024-03-22": "Establishment Day of the Lao People's Revolutionary Party",
"2024-04-13": "Lao New Year's Day",
"2024-04-14": "Lao New Year's Day; Lao People's Revolutionary Youth Union Day",
"2024-04-15": "Lao New Year's Day",
"2024-04-16": "Lao New Year's Day",
"2024-04-17": "Lao New Year's Day (in lieu)",
"2024-04-18": "Lao New Year's Day (in lieu)",
"2024-05-01": "International Labor Day",
"2024-05-22": "Visakha Bousa Festival",
"2024-06-01": "International Children Day; National Arbor Day",
Expand Down
Loading
Loading