Skip to content

Commit

Permalink
Add Bahamas holidays (#1517)
Browse files Browse the repository at this point in the history
Co-authored-by: ~Jhellico <KJhellico@users.noreply.github.com>
Co-authored-by: Arkadii Yakovets <ark@cho.red>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent f4287d3 commit 6be7ab9
Show file tree
Hide file tree
Showing 6 changed files with 1,251 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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 138 country codes. The standard way to refer to a country
We currently support 139 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 @@ -202,6 +202,11 @@ The list of supported countries, their subdivisions, supported languages and cat
-
-
-
* - Bahamas
- BS
-
-
-
* - Bahrain
- BH
-
Expand Down
1 change: 1 addition & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .australia import Australia, AU, AUS
from .austria import Austria, AT, AUT
from .azerbaijan import Azerbaijan, AZ, AZE
from .bahamas import Bahamas, BS, BHS
from .bahrain import Bahrain, BH, BAH
from .bangladesh import Bangladesh, BD, BGD
from .barbados import Barbados, BB, BRB
Expand Down
135 changes: 135 additions & 0 deletions holidays/countries/bahamas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# python-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: dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
# ryanss <ryanssdev@icloud.com> (c) 2014-2017
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from holidays.calendars.gregorian import SEP
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import (
ObservedHolidayBase,
TUE_TO_PREV_MON,
WED_THU_TO_NEXT_FRI,
SAT_SUN_TO_NEXT_MON,
SUN_TO_NEXT_MON,
SUN_TO_NEXT_TUE,
)


class Bahamas(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, StaticHolidays):
"""
References:
- https://en.wikipedia.org/wiki/Public_holidays_in_the_Bahamas
- https://laws.bahamas.gov.bs/cms/images/LEGISLATION/PRINCIPAL/1938/1938-0015/PublicHolidaysAct_1.pdf # noqa: E501
- https://laws.bahamas.gov.bs/cms/images/LEGISLATION/PRINCIPAL/2013/2013-0040/MajorityRulePublicHolidayAct2013_1.pdf # noqa: E501
- https://laws.bahamas.gov.bs/cms/images/LEGISLATION/PRINCIPAL/2013/2013-0009/RandolFawkesLabourDayAct2013_1.pdf # noqa: E501
- http://www.tribune242.com/news/2013/oct/12/national-heroes-day-formally-established/
- https://eleutheranews.com/?p=3594
Checked With:
- https://www.bahamashclondon.net/consular-information/public-holidays/
- https://bisxbahamas.com/wp-content/uploads/2020/12/Trading-Calendar-2021.pdf
- https://publicholidays.la/the-bahamas/2022-dates/ # Official source no longer accessible
"""

country = "BS"
observed_label = "%s (Observed)"

def __init__(self, *args, **kwargs):
ChristianHolidays.__init__(self)
InternationalHolidays.__init__(self)
StaticHolidays.__init__(self, BahamasStaticHolidays)
super().__init__(observed_rule=SAT_SUN_TO_NEXT_MON, *args, **kwargs)

def _populate_public_holidays(self):
# Gained Independence on Jul 10, 1973.
if self._year <= 1973:
return None

# New Year's Day.
# Pre-2012 Observance:
# - If TUE, New Year's Day (Observed) prev MON.
# - If WED or THU, New Year's Day (Observed) next FRI.
# 2012 and beyond Observance: If SUN, New Year's Day (Observed) next MON (not for SAT).
self._add_observed(
self._add_new_years_day("New Year's Day"),
rule=SUN_TO_NEXT_MON
if self._year >= 2012
else SAT_SUN_TO_NEXT_MON + TUE_TO_PREV_MON + WED_THU_TO_NEXT_FRI,
)

# Majority Rule Day.
# Officially made a holiday on Oct 11, 2013 under Majority Rule (Public Holiday) Act 2013.
if self._year >= 2014:
self._add_observed(self._add_holiday_jan_10("Majority Rule Day"))

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

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

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

# Randol Fawkes Labour Day.
# This was simply known as "Labour Day" prior to Randol Fawkes Labour Day Act 2013.
self._add_holiday_1st_fri_of_jun(
"Randol Fawkes Labour Day" if self._year >= 2013 else "Labour Day"
)

# Independence Day.
self._add_observed(self._add_holiday_jul_10("Independence Day"))

# Emancipation Day.
self._add_holiday_1st_mon_of_aug("Emancipation Day")

# National Heroes Day.
# Known as "Discovery Day" prior to 2013, with its date fixed as Oct 12 annually.
# Got its name changed on Oct 11, 2013 under Majority Rule (Public Holiday) Act 2013.
# Pre-2013 Observance:
# - If TUE, Discovery Day (Observed) prev MON.
# - If WED or THU, Discovery Day (Observed) next FRI.
if self._year >= 2013:
self._add_holiday_2nd_mon_of_oct("National Heroes Day")
else:
self._add_observed(
self._add_columbus_day("Discovery Day"),
rule=SAT_SUN_TO_NEXT_MON + TUE_TO_PREV_MON + WED_THU_TO_NEXT_FRI,
)

# Christmas Holidays Exception Rules.
# Observance Exception:
# FRI-SAT -> Boxing Day (Observed) next MON.
# SAT-SUN -> Boxing Day (Observed) next MON.
# SUN-MON -> Christmas Day (Observed) next TUE.

# 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"))

# New Year's Day observance overflow.
# This only applies to Pre-2012 observance.
if self.observed and self._year in {1979, 1984, 1990, 2001, 2007}:
self._add_new_years_eve("New Year's Day (Observed)")


class BS(Bahamas):
pass


class BHS(Bahamas):
pass


class BahamasStaticHolidays:
special_public_holidays = {
# https://www.bahamas.gov.bs/wps/portal/public/gov/government/notices/national%20holiday%2019th%20september/ # noqa: E501
2022: (SEP, 19, "State Funeral of Queen Elizabeth II"),
}
1 change: 1 addition & 0 deletions holidays/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"australia": ("Australia", "AU", "AUS"),
"austria": ("Austria", "AT", "AUT"),
"azerbaijan": ("Azerbaijan", "AZ", "AZE"),
"bahamas": ("Bahamas", "BS", "BHS"),
"bahrain": ("Bahrain", "BH", "BAH"),
"bangladesh": ("Bangladesh", "BD", "BGD"),
"barbados": ("Barbados", "BB", "BRB"),
Expand Down
Loading

0 comments on commit 6be7ab9

Please sign in to comment.