|
| 1 | +# holidays |
| 2 | +# -------- |
| 3 | +# A fast, efficient Python library for generating country, province and state |
| 4 | +# specific sets of holidays on the fly. It aims to make determining whether a |
| 5 | +# specific date is a holiday as fast and flexible as possible. |
| 6 | +# |
| 7 | +# Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) |
| 8 | +# dr-prodigy <[email protected]> (c) 2017-2023 |
| 9 | +# ryanss <[email protected]> (c) 2014-2017 |
| 10 | +# Website: https://github.com/vacanza/holidays |
| 11 | +# License: MIT (see LICENSE file) |
| 12 | + |
| 13 | +from gettext import gettext as tr |
| 14 | + |
| 15 | +from holidays import APR, MAY, JUN, JUL, SEP, NOV, DEC |
| 16 | +from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays |
| 17 | +from holidays.observed_holiday_base import ( |
| 18 | + ObservedHolidayBase, |
| 19 | + SAT_SUN_TO_NEXT_MON, |
| 20 | + SAT_SUN_TO_NEXT_MON_TUE, |
| 21 | +) |
| 22 | + |
| 23 | + |
| 24 | +class CaymanIslands(ObservedHolidayBase, ChristianHolidays, InternationalHolidays, StaticHolidays): |
| 25 | + """Cayman Islands holidays. |
| 26 | +
|
| 27 | + References: |
| 28 | + * <https://en.wikipedia.org/wiki/Public_holidays_in_the_Cayman_Islands> |
| 29 | + * [Public Holidays Law (2007 Revision)](https://web.archive.org/web/20250227060525/https://legislation.gov.ky/cms/images/LEGISLATION/PRINCIPAL/1964/1964-0140/PublicHolidaysAct_2007%20Revision_g.pdf) |
| 30 | + * [Public Holidays Order, 2024](https://web.archive.org/web/20240518181823/https://legislation.gov.ky/cms/images/LEGISLATION/AMENDING/2024/2024-O004/PublicHolidaysOrder2024SL4of2024.pdf) |
| 31 | + * [2006-2015](https://web.archive.org/web/20151014061601/http://www.gov.ky/portal/page?_pageid=1142,1592653&_dad=portal&_schema=PORTAL) |
| 32 | + * [2016-2018](https://web.archive.org/web/20180330170202/http://www.gov.ky:80/portal/page/portal/cighome/cayman/islands/publicholidays) |
| 33 | + * [2021](http://archive.today/2025.07.09-033240/https://www.gov.ky/news/press-release-details/public-holidays-for-2021) |
| 34 | + * [2022](http://archive.today/2025.07.09-033515/https://www.gov.ky/news/press-release-details/public-holidays-2022) |
| 35 | + * [2024](http://archive.today/2025.01.06-110234/https://www.gov.ky/calendar/public-holidays) |
| 36 | + * [2025](http://archive.today/2025.07.09-033853/https://www.gov.ky/calendar/public-holidays) |
| 37 | + """ |
| 38 | + |
| 39 | + country = "KY" |
| 40 | + default_language = "en_GB" |
| 41 | + # %s observed. |
| 42 | + observed_label = tr("%s (observed)") |
| 43 | + # Earliest year of holidays with an accessible online record. |
| 44 | + start_year = 2006 |
| 45 | + supported_languages = ("en_GB", "en_US") |
| 46 | + |
| 47 | + def __init__(self, *args, **kwargs): |
| 48 | + ChristianHolidays.__init__(self) |
| 49 | + InternationalHolidays.__init__(self) |
| 50 | + StaticHolidays.__init__(self, cls=CaymanIslandsStaticHolidays) |
| 51 | + kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_MON) |
| 52 | + super().__init__(*args, **kwargs) |
| 53 | + |
| 54 | + def _populate_public_holidays(self): |
| 55 | + # New Year's Day. |
| 56 | + self._add_observed(self._add_new_years_day(tr("New Year's Day"))) |
| 57 | + |
| 58 | + # National Heroes Day. |
| 59 | + self._add_holiday_4th_mon_of_jan(tr("National Heroes Day")) |
| 60 | + |
| 61 | + # Ash Wednesday. |
| 62 | + self._add_ash_wednesday(tr("Ash Wednesday")) |
| 63 | + |
| 64 | + # Good Friday. |
| 65 | + self._add_good_friday(tr("Good Friday")) |
| 66 | + |
| 67 | + # Easter Monday. |
| 68 | + self._add_easter_monday(tr("Easter Monday")) |
| 69 | + |
| 70 | + if self._year >= 2024: |
| 71 | + # Emancipation Day. |
| 72 | + self._add_holiday_1st_mon_of_may(tr("Emancipation Day")) |
| 73 | + |
| 74 | + # Discovery Day. |
| 75 | + self._add_holiday_3rd_mon_of_may(tr("Discovery Day")) |
| 76 | + |
| 77 | + if self._year <= 2022: |
| 78 | + queens_birthday_dates = { |
| 79 | + 2007: (JUN, 18), |
| 80 | + 2012: (JUN, 18), |
| 81 | + 2013: (JUN, 17), |
| 82 | + 2017: (JUN, 19), |
| 83 | + 2022: (JUN, 6), |
| 84 | + } |
| 85 | + # Queen's Birthday. |
| 86 | + name = tr("Queen's Birthday") |
| 87 | + if dt := queens_birthday_dates.get(self._year): |
| 88 | + self._add_holiday(name, dt) |
| 89 | + else: |
| 90 | + self._add_holiday_2_days_past_2nd_sat_of_jun(name) |
| 91 | + else: |
| 92 | + # King's Birthday. |
| 93 | + self._add_holiday_2_days_past_3rd_sat_of_jun(tr("King's Birthday")) |
| 94 | + |
| 95 | + # Constitution Day. |
| 96 | + self._add_holiday_1st_mon_of_jul(tr("Constitution Day")) |
| 97 | + |
| 98 | + # Remembrance Day. |
| 99 | + self._add_holiday_2nd_mon_of_nov(tr("Remembrance Day")) |
| 100 | + |
| 101 | + self._add_observed( |
| 102 | + # Christmas Day. |
| 103 | + self._add_christmas_day(tr("Christmas Day")), |
| 104 | + rule=SAT_SUN_TO_NEXT_MON_TUE, |
| 105 | + ) |
| 106 | + |
| 107 | + self._add_observed( |
| 108 | + # Boxing Day. |
| 109 | + self._add_christmas_day_two(tr("Boxing Day")), |
| 110 | + rule=SAT_SUN_TO_NEXT_MON_TUE, |
| 111 | + ) |
| 112 | + |
| 113 | + |
| 114 | +class KY(CaymanIslands): |
| 115 | + pass |
| 116 | + |
| 117 | + |
| 118 | +class CYM(CaymanIslands): |
| 119 | + pass |
| 120 | + |
| 121 | + |
| 122 | +class CaymanIslandsStaticHolidays: |
| 123 | + """Cayman Islands special holidays. |
| 124 | +
|
| 125 | + References: |
| 126 | + * [Public Holidays Order, 2009](https://archive.org/details/public-holidays-order-2009-sl-33-of-2009) |
| 127 | + * [Public Holidays Order (No. 2), 2019](https://archive.org/details/public-holidays-no.-2-order-2019-sl-38-of-2019) |
| 128 | + * [Public Holidays Order, 2025](https://archive.org/details/public-holidays-order-2025-sl-15-of-2025) |
| 129 | + * [Referendum Day 2019](https://web.archive.org/web/20250711121821/https://www.facebook.com/ElectionsOffice/posts/reminder-the-referendum-vote-has-been-postponed-and-will-no-longer-take-place-th/2619995141431734/?_rdc=2&_rdr) |
| 130 | + * [UK Royal Wedding](https://en.wikipedia.org/wiki/Wedding_of_Prince_William_and_Catherine_Middleton) |
| 131 | + * [Queen Elizabeth II's Diamond Jubilee](https://web.archive.org/web/20210803202236/https://www.caymancompass.com/2012/06/06/queens-diamond-jubilee-feted/) |
| 132 | + * [Queen Elizabeth II's Funeral](https://web.archive.org/web/20231226055510/https://www.caymancompass.com/2022/09/12/cayman-declares-public-holiday-for-queens-funeral/) |
| 133 | + * [King Charles III's Coronation](https://web.archive.org/web/20250601214328/https://www.radiocayman.gov.ky/news/public-holidays-for-2023-unconfirmed) |
| 134 | + """ |
| 135 | + |
| 136 | + # Referendum Day. |
| 137 | + referendum_day_name = tr("Referendum Day") |
| 138 | + # General Election Day. |
| 139 | + general_election_day_name = tr("General Election Day") |
| 140 | + special_public_holidays = { |
| 141 | + 2009: ( |
| 142 | + # 2009 Cayman Islands Constitution Day. |
| 143 | + (NOV, 6, tr("2009 Cayman Islands Constitution Day")), |
| 144 | + (MAY, 20, general_election_day_name), |
| 145 | + ), |
| 146 | + # UK Royal Wedding. |
| 147 | + 2011: (APR, 29, tr("UK Royal Wedding")), |
| 148 | + 2012: ( |
| 149 | + # Queen Elizabeth II's Diamond Jubilee. |
| 150 | + (JUN, 4, tr("Queen Elizabeth II's Diamond Jubilee")), |
| 151 | + (JUL, 18, referendum_day_name), |
| 152 | + ), |
| 153 | + 2013: (MAY, 22, general_election_day_name), |
| 154 | + 2017: (MAY, 24, general_election_day_name), |
| 155 | + 2019: (DEC, 19, referendum_day_name), |
| 156 | + 2021: (APR, 14, general_election_day_name), |
| 157 | + # Queen Elizabeth II's Funeral. |
| 158 | + 2022: (SEP, 19, tr("Queen Elizabeth II's Funeral")), |
| 159 | + # King Charles III's Coronation. |
| 160 | + 2023: (MAY, 8, tr("Coronation of His Majesty King Charles III")), |
| 161 | + 2025: (APR, 30, general_election_day_name), |
| 162 | + } |
0 commit comments