Skip to content

Commit

Permalink
Add Palau holidays (#1776)
Browse files Browse the repository at this point in the history
Co-authored-by: Arkadii Yakovets <ark@cho.red>
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 26, 2024
1 parent ec27521 commit 48f85eb
Show file tree
Hide file tree
Showing 8 changed files with 1,119 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,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 146 country codes. The standard way to refer to a country
We currently support 147 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 countries have common or foreign
names or abbreviations as aliases for their subdivisions. These are defined in
Expand Down Expand Up @@ -695,6 +695,11 @@ All other default values are highlighted with bold:
-
-
-
* - Palau
- PW
-
-
- ARMED_FORCES, HALF_DAY
* - Panama
- PA
-
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
from .northern_mariana_islands import NorthernMarianaIslands, MP, MNP, HolidaysMP
from .norway import Norway, NO, NOR
from .pakistan import Pakistan, PK, PAK
from .palau import Palau, PW, PLW
from .panama import Panama, PA, PAN
from .papua_new_guinea import PapuaNewGuinea, PG, PNG
from .paraguay import Paraguay, PY, PRY
Expand Down
127 changes: 127 additions & 0 deletions holidays/countries/palau.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# holidays
# --------
# A fast, efficient Python library for generating country, province and state
# specific sets of holidays on the fly. It aims to make determining whether a
# specific date is a holiday as fast and flexible as possible.
#
# Authors: Vacanza Team and individual contributors (see AUTHORS file)
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars.gregorian import SEP, NOV
from holidays.constants import ARMED_FORCES, HALF_DAY, PUBLIC
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_TO_PREV_FRI, SUN_TO_NEXT_MON


class Palau(ObservedHolidayBase, ChristianHolidays, InternationalHolidays):
"""
References:
- http://www.paclii.org/pw/legis/consol_act/gpt1262/ # Chapter 7, Holidays.
- https://www.palaugov.pw/wp-content/uploads/2017/11/RPPL-No.-10-15-re.-Family-Day-Holiday.pdf
- https://www.facebook.com/PalauPresident/posts/195883107230463 # EO336 Memorial Day repealed
- https://www.taiwanembassy.org/pal_en/post/792.html # Earliest source for President's Day
If any of the holidays enumerated in section 701 of this chapter falls on Sunday, the
following Monday shall be observed as a holiday. If any of the holidays enumerated in
section 701 of this chapter falls on Saturday, the preceding Friday shall be observed
as a holiday.
As there's no record of President's Day (Jun 1) and Independence Day (Oct 1) being
legal holiday before 2017, as seen in RPRL 10-15, they shall be assumed to start in 2018
for our current implementation.
"""

country = "PW"
supported_categories = (ARMED_FORCES, HALF_DAY, PUBLIC)
observed_label = "%s (observed)"

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
StaticHolidays.__init__(self, PalauStaticHolidays)
kwargs.setdefault("observed_rule", SAT_TO_PREV_FRI + SUN_TO_NEXT_MON)
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
# Republic of Palau Public Law No. 2-15.
# The legislation was first adopted by the 2nd Olbiil Era Kelulau (1984-1988),
# but since we cannot find any info on its actual adoption date, we may as
# well use the formation date of the country as the placeholder cut-off date.
if self._year <= 1980:
return None

# Fixed Date Public Holidays.

# New Year's Day.
name = "New Year's Day"
self._add_observed(self._add_new_years_day(name))
self._add_observed(self._next_year_new_years_day, name=name, rule=SAT_TO_PREV_FRI)

# Youth Day.
self._add_observed(self._add_holiday_mar_15("Youth Day"))

# Senior Citizens Day.
self._add_observed(self._add_holiday_may_5("Senior Citizens Day"))

if self._year in {2011, 2012}:
# Memorial Day.
self._add_holiday_last_mon_of_may("Memorial Day")

if self._year >= 2018:
# President's Day.
self._add_observed(self._add_holiday_jun_1("President's Day"))

# Constitution Day.
self._add_observed(self._add_holiday_jul_9("Constitution Day"))

# Labor Day.
self._add_holiday_1st_mon_of_sep("Labor Day")

if self._year >= 2018:
# Independence Day.
self._add_observed(self._add_holiday_oct_1("Independence Day"))

# United Nations Day.
self._add_observed(self._add_united_nations_day("United Nations Day"))

# Thanksgiving Day.
self._add_holiday_4th_thu_of_nov("Thanksgiving Day")

if self._year >= 2017:
# Family Day.
self._add_holiday_4th_fri_of_nov("Family Day")

# Christmas Day.
self._add_observed(self._add_christmas_day("Christmas Day"))


class PW(Palau):
pass


class PLW(Palau):
pass


class PalauStaticHolidays:
"""
Sources:
- https://www.facebook.com/photo?fbid=1774513196034105&set=a.175933635892077
- https://www.facebook.com/photo/?fbid=1794692910682800&set=a.175933635892077
- https://www.facebook.com/photo/?fbid=1408133829338712&set=a.175933635892077
"""

special_armed_forces_holidays = {
2020: (NOV, 11, "Veterans Day"),
}

special_half_day_holidays = {
2019: (SEP, 30, "Preparation for the 25th Independence Day of the Republic of Palau"),
}

special_public_holidays = {
2020: (NOV, 3, "National Day of Democracy"),
}
2 changes: 1 addition & 1 deletion holidays/countries/south_korea.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def add_three_day_holiday(dt: date, name: str):

if 1950 <= self._year <= 1975:
# United Nations Day.
self._add_holiday_oct_24(tr("국제연합일"))
self._add_united_nations_day(tr("국제연합일"))

# Chuseok.
name = tr("추석")
Expand Down
10 changes: 10 additions & 0 deletions holidays/groups/international.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,13 @@ def _add_world_war_two_victory_day(self, name):
https://en.wikipedia.org/wiki/Victory_Day_(9_May)
"""
return self._add_holiday_may_9(name)

def _add_united_nations_day(self, name):
"""
Add United Nations Day (Oct 24th)
United Nations Day is an annual commemorative day, reflecting the
official creation of the United Nations on 24 October 1945.
https://en.wikipedia.org/wiki/United_Nations_Day
"""
return self._add_holiday_oct_24(name)
1 change: 1 addition & 0 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"northern_mariana_islands": ("NorthernMarianaIslands", "MP", "MNP", "HolidaysMP"),
"norway": ("Norway", "NO", "NOR"),
"pakistan": ("Pakistan", "PK", "PAK"),
"palau": ("Palau", "PW", "PLW"),
"panama": ("Panama", "PA", "PAN"),
"papua_new_guinea": ("PapuaNewGuinea", "PG", "PNG"),
"paraguay": ("Paraguay", "PY", "PRY"),
Expand Down

0 comments on commit 48f85eb

Please sign in to comment.