|
| 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.calendars import _CustomChineseHolidays, _CustomIslamicHolidays |
| 16 | +from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC |
| 17 | +from holidays.groups import ( |
| 18 | + ChineseCalendarHolidays, |
| 19 | + ChristianHolidays, |
| 20 | + InternationalHolidays, |
| 21 | + IslamicHolidays, |
| 22 | + StaticHolidays, |
| 23 | +) |
| 24 | +from holidays.observed_holiday_base import ( |
| 25 | + ObservedHolidayBase, |
| 26 | + MON_TO_NEXT_TUE, |
| 27 | + SAT_SUN_TO_NEXT_MON, |
| 28 | + SAT_SUN_TO_NEXT_MON_TUE, |
| 29 | +) |
| 30 | + |
| 31 | + |
| 32 | +class ChristmasIsland( |
| 33 | + ObservedHolidayBase, |
| 34 | + ChineseCalendarHolidays, |
| 35 | + ChristianHolidays, |
| 36 | + InternationalHolidays, |
| 37 | + IslamicHolidays, |
| 38 | + StaticHolidays, |
| 39 | +): |
| 40 | + """Christmas Island holidays. |
| 41 | +
|
| 42 | + References: |
| 43 | + * <https://en.wikipedia.org/wiki/Public_holidays_in_Christmas_Island> |
| 44 | + * [2007](https://web.archive.org/web/20250612072036/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2006/01-2006_Public_Holidays_2007_CI.doc) |
| 45 | + * [2008](https://web.archive.org/web/20240224131231/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2007/05-2007_Public_Holidays_CI.pdf) |
| 46 | + * [2008 Hari Raya Puasa](https://web.archive.org/web/20240331104649/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2008/03_2008_Observance_of_Hari_Raya_Puasa_2008.pdf) |
| 47 | + * [2009](https://web.archive.org/web/20231211180406/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2008/02-2008_2009_public_holiday_CI_gazette.pdf) |
| 48 | + * [2010](https://web.archive.org/web/20250612051603/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2009/2009-Gazette_5-2009-CI-Proclamation_of_2010_Special_Public_and_Bank_Holidays.pdf) |
| 49 | + * [2013](https://web.archive.org/web/20240805060802/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2012/2012-Gazette_7-2012-CI-Proclamation_of_2013_Public_Holidays_for_Christmas_Island.pdf) |
| 50 | + * [2014](https://web.archive.org/web/20240718175750/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2013/2013-Gazette_2-2013-Christmas_Island_2014_Public_Holidays.pdf) |
| 51 | + * [2016 Hari Raya Puasa](https://web.archive.org/web/20240222235345/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2016/2016-Gazette_4-2016-CI-Proclamation_Special_Public_and_Bank_Holidays_2016.pdf) |
| 52 | + * [2017](https://web.archive.org/web/20240226014639/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_gazette/files/2016/2016-Gazette_1-2016-CI-Proclamation_Special_Public_and_Bank_Holidays_2017.pdf) |
| 53 | + * [2019](https://web.archive.org/web/20250517064053/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_bulletins/2018/files/A37-2018.pdf) |
| 54 | + * [2020](https://web.archive.org/web/20240830230128/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_bulletins/2019/files/A52-2019.pdf) |
| 55 | + * [2021](https://web.archive.org/web/20240713155232/https://www.infrastructure.gov.au/sites/default/files/migrated/territories/indian_ocean/iot_bulletins/2020/files/a40-ci-public-holidays-2021-proclamation.pdf) |
| 56 | + * [2022](https://web.archive.org/web/20240626092850/https://www.infrastructure.gov.au/sites/default/files/documents/a32-2021-2022-public-holidays-christmas-island.pdf) |
| 57 | + * [2023](https://web.archive.org/web/20250612044842/https://www.infrastructure.gov.au/sites/default/files/documents/A06-2022-notice-proclamation-special-public-bank-holidays-2023-ci.pdf) |
| 58 | + * [2023 Hari Raya Haji](https://web.archive.org/web/20240804112114/https://www.infrastructure.gov.au/sites/default/files/documents/a06-2023_community_bulletin_-_change_of_public_holiday_date_for_hari_raya_haji_2023.pdf) |
| 59 | + * [2024](https://web.archive.org/web/20240519034837/https://www.infrastructure.gov.au/sites/default/files/documents/a11-2023-2024-public-holidays-christmas-island.pdf) |
| 60 | + * [2025](https://web.archive.org/web/20250610185153/https://www.infrastructure.gov.au/sites/default/files/documents/a20-2024-administrator-community-bulletin-ci-public-holidays-2025.pdf) |
| 61 | + """ |
| 62 | + |
| 63 | + country = "CX" |
| 64 | + default_language = "en_CX" |
| 65 | + # %s (observed). |
| 66 | + observed_label = tr("%s (observed)") |
| 67 | + # %s (estimated). |
| 68 | + estimated_label = tr("%s (estimated)") |
| 69 | + # %s (observed, estimated). |
| 70 | + observed_estimated_label = tr("%s (observed, estimated)") |
| 71 | + supported_languages = ("en_CX", "en_US") |
| 72 | + start_year = 2007 |
| 73 | + |
| 74 | + def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs): |
| 75 | + ChineseCalendarHolidays.__init__(self, cls=ChristmasIslandChineseHolidays) |
| 76 | + ChristianHolidays.__init__(self) |
| 77 | + InternationalHolidays.__init__(self) |
| 78 | + IslamicHolidays.__init__( |
| 79 | + self, cls=ChristmasIslandIslamicHolidays, show_estimated=islamic_show_estimated |
| 80 | + ) |
| 81 | + StaticHolidays.__init__(self, ChristmasIslandStaticHolidays) |
| 82 | + kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_MON) |
| 83 | + super().__init__(*args, **kwargs) |
| 84 | + |
| 85 | + def _populate_public_holidays(self): |
| 86 | + # New Year's Day. |
| 87 | + self._add_observed(self._add_new_years_day(tr("New Year's Day"))) |
| 88 | + |
| 89 | + # Australia Day. |
| 90 | + self._add_observed(self._add_holiday_jan_26(tr("Australia Day"))) |
| 91 | + |
| 92 | + # Chinese New Year. |
| 93 | + name = tr("Chinese New Year") |
| 94 | + if self._year != 2020: |
| 95 | + self._add_observed(self._add_chinese_new_years_day(name), rule=SAT_SUN_TO_NEXT_MON_TUE) |
| 96 | + self._add_observed( |
| 97 | + self._add_chinese_new_years_day_two(name), rule=SAT_SUN_TO_NEXT_MON_TUE |
| 98 | + ) |
| 99 | + |
| 100 | + # Labor Day. |
| 101 | + name = tr("Labour Day") |
| 102 | + if self._year in {2009, 2010, 2014, 2021, 2025}: |
| 103 | + self._add_holiday_4th_mon_of_mar(name) |
| 104 | + else: |
| 105 | + self._add_holiday_3rd_mon_of_mar(name) |
| 106 | + |
| 107 | + # Good Friday. |
| 108 | + self._add_good_friday(tr("Good Friday")) |
| 109 | + |
| 110 | + # ANZAC Day. |
| 111 | + self._add_observed(self._add_anzac_day(tr("ANZAC Day"))) |
| 112 | + |
| 113 | + # Territory Day. |
| 114 | + self._add_holiday_1st_mon_of_oct(tr("Territory Day")) |
| 115 | + |
| 116 | + self._add_observed( |
| 117 | + # Boxing Day. |
| 118 | + self._add_christmas_day_two(tr("Boxing Day")), |
| 119 | + rule=SAT_SUN_TO_NEXT_MON_TUE + MON_TO_NEXT_TUE, |
| 120 | + ) |
| 121 | + |
| 122 | + # Christmas Day. |
| 123 | + self._add_observed(self._add_christmas_day(tr("Christmas Day"))) |
| 124 | + |
| 125 | + # Eid al-Fitr. |
| 126 | + for dt in self._add_eid_al_fitr_day(tr("Hari Raya Puasa")): |
| 127 | + self._add_observed(dt) |
| 128 | + |
| 129 | + # Eid al-Adha. |
| 130 | + for dt in self._add_eid_al_adha_day(tr("Hari Raya Haji")): |
| 131 | + if self._year not in {2014, 2025}: |
| 132 | + self._add_observed(dt) |
| 133 | + |
| 134 | + |
| 135 | +class ChristmasIslandChineseHolidays(_CustomChineseHolidays): |
| 136 | + LUNAR_NEW_YEAR_DATES = { |
| 137 | + 2007: (FEB, 19), |
| 138 | + 2009: (JAN, 27), |
| 139 | + 2010: (FEB, 15), |
| 140 | + 2023: (JAN, 23), |
| 141 | + } |
| 142 | + |
| 143 | + |
| 144 | +class ChristmasIslandIslamicHolidays(_CustomIslamicHolidays): |
| 145 | + EID_AL_ADHA_DATES = { |
| 146 | + 2007: (DEC, 20), |
| 147 | + 2008: (DEC, 8), |
| 148 | + 2009: (NOV, 30), |
| 149 | + 2010: (NOV, 16), |
| 150 | + 2013: (OCT, 15), |
| 151 | + 2014: (OCT, 5), |
| 152 | + 2016: (SEP, 13), |
| 153 | + 2017: (SEP, 1), |
| 154 | + 2019: (AUG, 11), |
| 155 | + 2020: (JUL, 31), |
| 156 | + 2021: (JUL, 20), |
| 157 | + 2022: (JUL, 9), |
| 158 | + 2023: (JUN, 28), |
| 159 | + 2024: (JUN, 17), |
| 160 | + 2025: (JUN, 7), |
| 161 | + } |
| 162 | + |
| 163 | + EID_AL_FITR_DATES = { |
| 164 | + 2007: (OCT, 15), |
| 165 | + 2008: (OCT, 1), |
| 166 | + 2009: (SEP, 21), |
| 167 | + 2010: (SEP, 10), |
| 168 | + 2013: (AUG, 8), |
| 169 | + 2014: (JUL, 28), |
| 170 | + 2016: (JUL, 6), |
| 171 | + 2017: (JUN, 24), |
| 172 | + 2019: (JUN, 5), |
| 173 | + 2020: (MAY, 24), |
| 174 | + 2021: (MAY, 13), |
| 175 | + 2022: (MAY, 2), |
| 176 | + 2023: (APR, 22), |
| 177 | + 2024: (APR, 10), |
| 178 | + 2025: (MAR, 31), |
| 179 | + } |
| 180 | + |
| 181 | + |
| 182 | +class CX(ChristmasIsland): |
| 183 | + pass |
| 184 | + |
| 185 | + |
| 186 | +class CXR(ChristmasIsland): |
| 187 | + pass |
| 188 | + |
| 189 | + |
| 190 | +class ChristmasIslandStaticHolidays: |
| 191 | + """Christmas Island special holidays. |
| 192 | +
|
| 193 | + References: |
| 194 | + * [National Day of Mourning 2022](https://web.archive.org/web/20240712013008/https://www.infrastructure.gov.au/sites/default/files/documents/03-2022-proclamation-ci-day-of-mourning.pdf) |
| 195 | + """ |
| 196 | + |
| 197 | + # Chinese New Year. |
| 198 | + chinese_new_year = tr("Chinese New Year") |
| 199 | + |
| 200 | + # Eid al-Adha. |
| 201 | + eid_al_adha = tr("Hari Raya Haji") |
| 202 | + |
| 203 | + special_public_holidays = { |
| 204 | + # National Day of Mourning for Queen Elizabeth II. |
| 205 | + 2022: (SEP, 22, tr("National Day of Mourning for Queen Elizabeth II")), |
| 206 | + } |
| 207 | + |
| 208 | + special_public_holidays_observed = { |
| 209 | + 2014: (OCT, 7, eid_al_adha), |
| 210 | + 2020: ( |
| 211 | + (JAN, 28, chinese_new_year), |
| 212 | + (JAN, 29, chinese_new_year), |
| 213 | + ), |
| 214 | + 2025: (JUN, 6, eid_al_adha), |
| 215 | + } |
0 commit comments