Skip to content

Commit

Permalink
Add Dominica holidays (#1956)
Browse files Browse the repository at this point in the history
  • Loading branch information
PPsyrius authored Aug 28, 2024
1 parent e9c1b3d commit a2aeae9
Show file tree
Hide file tree
Showing 6 changed files with 1,298 additions and 1 deletion.
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 151 country codes. The standard way to refer to a country
We currently support 152 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 @@ -385,6 +385,11 @@ All other default values are highlighted with bold:
-
- ar, en_US, **fr**
-
* - Dominica
- DM
-
-
-
* - Dominican Republic
- DO
-
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from .czechia import Czechia, CZ, CZE
from .denmark import Denmark, DK, DNK
from .djibouti import Djibouti, DJ, DJI
from .dominica import Dominica, DM, DMA
from .dominican_republic import DominicanRepublic, DO, DOM
from .ecuador import Ecuador, EC, ECU
from .egypt import Egypt, EG, EGY
Expand Down
130 changes: 130 additions & 0 deletions holidays/countries/dominica.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# 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 <[email protected]> (c) 2017-2023
# ryanss <[email protected]> (c) 2014-2017
# Website: https://github.com/vacanza/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars.gregorian import JAN, JUL, SEP
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SUN_TO_NEXT_MON, SUN_TO_NEXT_TUE


class Dominica(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, StaticHolidays):
"""
References:
- https://www.dominica.gov.dm/laws/chapters/chap19-10.pdf
- https://pressroomopm.gov.dm/notice-public-holiday-order-2022/
- https://en.wikipedia.org/wiki/Public_holidays_in_Dominica
- https://dominica.gov.dm/laws/1998/sro1-1998.pdf
Cross-Checked With:
- https://www.dominica-weekly.com/images/dominica-calendar-2010/1600-1280.jpg # 2010
- https://dominicaconsulategreece.com/dominica/public-holidays/ # 2011-2020
- http://www.q95da.com/news/q95-news-received-on-december-29-2020-at-731pm-the-official-public-holiday-calendar-for-2021-approved-by-the-government-of-dominica
- https://dominica.gov.dm/about-dominica/public-holidays # 2022-2024
While Labour Day is listed in the 1990 amendment as May 1st, this has, de facto, been
made 1st Monday of May since at least 2010.
Where in any year two public holidays fall on the same day, then the next succeeding day
not being itself a public holiday shall be observed as a public holiday. In practice, this
only applies to Holidays which falls on Saturday or Sunday.
"""

country = "DM"
observed_label = "%s (observed)"

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

def _populate_public_holidays(self):
# Public Holidays Act, L.I. 12 of 1990 Amendment.
if self._year <= 1989:
return None

# New Year's Day.
self._add_observed(self._add_new_years_day("New Year's Day"))

# Carnival Monday.
self._add_carnival_monday("Carnival Monday")

# Carnival Tuesday.
self._add_carnival_tuesday("Carnival Tuesday")

# Good Friday.
self._add_good_friday("Good Friday")

# Easter Monday.
self._add_easter_monday("Easter Monday")

# Labour Day.
labour_day_name = "Labour Day"
if self._year >= 2010:
self._add_holiday_1st_mon_of_may(labour_day_name)
else:
self._add_observed(self._add_labor_day(labour_day_name))

# Whit Monday.
self._add_whit_monday("Whit Monday")

first_monday_of_august_holiday_name = (
# Emancipation Day.
"Emancipation Day"
if self._year >= 1998
# First Monday of August.
else "First Monday of August"
)
self._add_holiday_1st_mon_of_aug(first_monday_of_august_holiday_name)

# Independence Day.
self._add_observed(self._add_holiday_nov_3("Independence Day"), rule=SUN_TO_NEXT_TUE)

# National Day of Community Service .
self._add_observed(self._add_holiday_nov_4("National Day of Community Service"))

# Christmas Day.
self._add_observed(self._add_christmas_day("Christmas Day"), rule=SUN_TO_NEXT_TUE)

# Boxing Day.
self._add_observed(self._add_christmas_day_two("Boxing Day"))


class DM(Dominica):
pass


class DMA(Dominica):
pass


class DominicaStaticHolidays:
"""
References
- https://qppstudio-public-holidays-news.blogspot.com/2009/07/dominica-declares-july-28-public.html
- https://dominica.gov.dm/laws/2009/sro35-2009.pdf
- https://dominica.gov.dm/laws/2009/sro55-2009.pdf
- https://emonewsdm.com/thursday-september-19-2019-declared-public-holiday-in-dominica/
"""

# Special Public Holidays.
special_public_holiday_name = "Special Public Holiday"

special_public_holidays = {
2009: (
(JUL, 28, special_public_holiday_name),
(SEP, 3, special_public_holiday_name),
),
2010: (JAN, 4, special_public_holiday_name),
# Post-Hurricane Maria Thanksgiving Celebrations.
2019: (SEP, 19, "Post-Hurricane Maria Thanksgiving Celebrations"),
}
1 change: 1 addition & 0 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"czechia": ("Czechia", "CZ", "CZE"),
"denmark": ("Denmark", "DK", "DNK"),
"djibouti": ("Djibouti", "DJ", "DJI"),
"dominica": ("Dominica", "DM", "DMA"),
"dominican_republic": ("DominicanRepublic", "DO", "DOM"),
"ecuador": ("Ecuador", "EC", "ECU"),
"egypt": ("Egypt", "EG", "EGY"),
Expand Down
Loading

0 comments on commit a2aeae9

Please sign in to comment.