|
| 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 _CustomIslamicHolidays |
| 16 | +from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC |
| 17 | +from holidays.constants import PUBLIC, WORKDAY |
| 18 | +from holidays.groups import InternationalHolidays, IslamicHolidays, StaticHolidays |
| 19 | +from holidays.holiday_base import HolidayBase |
| 20 | + |
| 21 | + |
| 22 | +class Libya(HolidayBase, InternationalHolidays, IslamicHolidays, StaticHolidays): |
| 23 | + """Libya holidays. |
| 24 | +
|
| 25 | + References: |
| 26 | + * [Law No. 4 of 1987](https://web.archive.org/web/20250629084625/https://lawsociety.ly/legislation/قانون-رقم-4-لسنة-1987-م-بشأن-العطلات-الرسمية/) |
| 27 | + * [Law No. 5 of 2012](https://web.archive.org/web/20250629084558/https://lawsociety.ly/legislation/القانون-رقم-5-لسنة-2012-م-بشأن-العطلات-الرسم/) |
| 28 | + * [National Environmental Sanitation Day](https://web.archive.org/web/20250629084547/https://lawsociety.ly/legislation/قرار-رقم-414-لسنة-2021-م-باعتبار-يوم-14-أغسطس-يو/) |
| 29 | + """ |
| 30 | + |
| 31 | + country = "LY" |
| 32 | + default_language = "ar" |
| 33 | + # %s (estimated). |
| 34 | + estimated_label = tr("%s (المقدرة)") |
| 35 | + start_year = 1988 |
| 36 | + supported_categories = (PUBLIC, WORKDAY) |
| 37 | + supported_languages = ("ar", "en_US") |
| 38 | + |
| 39 | + def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs): |
| 40 | + """ |
| 41 | + Args: |
| 42 | + islamic_show_estimated: |
| 43 | + Whether to add "estimated" label to Islamic holidays name |
| 44 | + if holiday date is estimated. |
| 45 | + """ |
| 46 | + InternationalHolidays.__init__(self) |
| 47 | + IslamicHolidays.__init__( |
| 48 | + self, cls=LibyaIslamicHolidays, show_estimated=islamic_show_estimated |
| 49 | + ) |
| 50 | + StaticHolidays.__init__(self, cls=LibyaStaticHolidays) |
| 51 | + super().__init__(*args, **kwargs) |
| 52 | + |
| 53 | + def _populate_public_holidays(self): |
| 54 | + if self._year <= 2011: |
| 55 | + # People's Authority Day. |
| 56 | + self._add_holiday_mar_2(tr("عید إعلان سلطة الشعب")) |
| 57 | + |
| 58 | + # American Forces Evacuation Day. |
| 59 | + self._add_holiday_jun_11(tr("عيد إجلاء القوات الأمريكية")) |
| 60 | + |
| 61 | + # Glorious July Revolution Day. |
| 62 | + self._add_holiday_jul_23(tr("عيد ثورة يوليو المجيدة")) |
| 63 | + |
| 64 | + # Great Al-Fateh Revolution Day. |
| 65 | + self._add_holiday_sep_1(tr("عيد الفاتح العظيم")) |
| 66 | + else: |
| 67 | + # Anniversary of the February 17 Revolution. |
| 68 | + self._add_holiday_feb_17(tr("ثورة 17 فبراير")) |
| 69 | + |
| 70 | + # Labor Day. |
| 71 | + self._add_labor_day(tr("عيد العمال")) |
| 72 | + |
| 73 | + if self._year >= 2022: |
| 74 | + # National Environmental Sanitation Day. |
| 75 | + self._add_holiday_aug_14(tr("يوم وطني للإصحاح البيئي")) |
| 76 | + |
| 77 | + # Martyrs' Day. |
| 78 | + self._add_holiday_sep_16(tr("يوم الشهيد")) |
| 79 | + |
| 80 | + # Liberation Day. |
| 81 | + self._add_holiday_oct_23(tr("يوم التحرير")) |
| 82 | + |
| 83 | + # Independence Day. |
| 84 | + self._add_holiday_dec_24(tr("عيد الاستقلال")) |
| 85 | + |
| 86 | + # Islamic New Year. |
| 87 | + self._add_islamic_new_year_day(tr("عيد رأس السنة الهجرية")) |
| 88 | + |
| 89 | + # Prophet's Birthday. |
| 90 | + self._add_mawlid_day(tr("ذكرى المولد النبوي الشريف")) |
| 91 | + |
| 92 | + # Eid al-Fitr. |
| 93 | + name = tr("عيد الفطر") |
| 94 | + self._add_eid_al_fitr_day(name) |
| 95 | + self._add_eid_al_fitr_day_two(name) |
| 96 | + self._add_eid_al_fitr_day_three(name) |
| 97 | + |
| 98 | + # Day of Arafah. |
| 99 | + self._add_arafah_day(tr("يوم عرفة")) |
| 100 | + |
| 101 | + # Eid al-Adha. |
| 102 | + name = tr("عيد الأضحى") |
| 103 | + self._add_eid_al_adha_day(name) |
| 104 | + self._add_eid_al_adha_day_two(name) |
| 105 | + self._add_eid_al_adha_day_three(name) |
| 106 | + |
| 107 | + def _populate_workday_holidays(self): |
| 108 | + if self._year <= 2011: |
| 109 | + # Syrian Revolution Day. |
| 110 | + self._add_holiday_mar_8(tr("عيد ثورة سوريا")) |
| 111 | + |
| 112 | + # Anniversary of the Arab League. |
| 113 | + self._add_holiday_mar_22(tr("ذكرى إنشاء الجامعة العربية")) |
| 114 | + |
| 115 | + # British Forces Evacuation Day. |
| 116 | + self._add_holiday_mar_28(tr("عيد إجلاء القوات البريطانية")) |
| 117 | + |
| 118 | + # Italian Forces Evacuation Day. |
| 119 | + self._add_holiday_oct_7(tr("عيد إجلاء الطليان")) |
| 120 | + |
| 121 | + # Islamic New Year. |
| 122 | + self._add_islamic_new_year_day(tr("عيد رأس السنة الهجرية")) |
| 123 | + |
| 124 | + # Ashura. |
| 125 | + self._add_ashura_day(tr("عاشوراء")) |
| 126 | + |
| 127 | + # Isra and Mi'raj. |
| 128 | + self._add_isra_and_miraj_day(tr("ذكرى الإسراء والمعراج")) |
| 129 | + |
| 130 | + # Night of Forgiveness. |
| 131 | + self._add_imam_mahdi_birthday_day(tr("ليلة النصف من شعبان")) |
| 132 | + |
| 133 | + |
| 134 | +class LY(Libya): |
| 135 | + pass |
| 136 | + |
| 137 | + |
| 138 | +class LBY(Libya): |
| 139 | + pass |
| 140 | + |
| 141 | + |
| 142 | +class LibyaIslamicHolidays(_CustomIslamicHolidays): |
| 143 | + # https://web.archive.org/web/20240908234803/https://www.timeanddate.com/holidays/libya/eid-al-adha |
| 144 | + # https://web.archive.org/web/20250629084537/https://lawsociety.ly/legislation/قرار-رقم-773-لسنة-2017-م-بشأن-تحديد-عطلة-عيد-ال/ |
| 145 | + EID_AL_ADHA_DATES = { |
| 146 | + 2012: (OCT, 26), |
| 147 | + 2013: (OCT, 15), |
| 148 | + 2014: (OCT, 5), |
| 149 | + 2015: (SEP, 23), |
| 150 | + 2016: (SEP, 11), |
| 151 | + 2017: (SEP, 1), |
| 152 | + 2018: (AUG, 22), |
| 153 | + 2019: (AUG, 11), |
| 154 | + 2020: (JUL, 31), |
| 155 | + 2021: (JUL, 20), |
| 156 | + 2022: (JUL, 9), |
| 157 | + 2023: (JUN, 28), |
| 158 | + 2024: (JUN, 16), |
| 159 | + 2025: (JUN, 6), |
| 160 | + } |
| 161 | + |
| 162 | + # https://web.archive.org/web/20241012125707/https://www.timeanddate.com/holidays/libya/eid-al-fitr |
| 163 | + EID_AL_FITR_DATES = { |
| 164 | + 2012: (AUG, 19), |
| 165 | + 2013: (AUG, 8), |
| 166 | + 2014: (JUL, 29), |
| 167 | + 2015: (JUL, 18), |
| 168 | + 2016: (JUL, 7), |
| 169 | + 2017: (JUN, 26), |
| 170 | + 2018: (JUN, 15), |
| 171 | + 2019: (JUN, 4), |
| 172 | + 2020: (MAY, 24), |
| 173 | + 2021: (MAY, 13), |
| 174 | + 2022: (MAY, 2), |
| 175 | + 2023: (APR, 21), |
| 176 | + 2024: (APR, 10), |
| 177 | + 2025: (MAR, 31), |
| 178 | + } |
| 179 | + |
| 180 | + # https://web.archive.org/web/20250418094505/https://www.timeanddate.com/holidays/libya/muharram-new-year |
| 181 | + HIJRI_NEW_YEAR_DATES = { |
| 182 | + 2012: (NOV, 15), |
| 183 | + 2013: (NOV, 5), |
| 184 | + 2014: (OCT, 25), |
| 185 | + 2015: (OCT, 15), |
| 186 | + 2016: (OCT, 3), |
| 187 | + 2017: (SEP, 22), |
| 188 | + 2018: (SEP, 12), |
| 189 | + 2019: (AUG, 31), |
| 190 | + 2020: (AUG, 20), |
| 191 | + 2021: (AUG, 10), |
| 192 | + 2022: (JUL, 30), |
| 193 | + 2023: (JUL, 19), |
| 194 | + 2024: (JUL, 7), |
| 195 | + 2025: (JUN, 26), |
| 196 | + } |
| 197 | + |
| 198 | + # https://web.archive.org/web/20241213175353/https://www.timeanddate.com/holidays/libya/prophet-birthday |
| 199 | + # https://web.archive.org/web/20250629084607/https://lawsociety.ly/legislation/قرار-رقم-1299-لسنة-2019-م-بشأن-عطلة-ذكرى-المولد/ |
| 200 | + MAWLID_DATES = { |
| 201 | + 2012: (FEB, 5), |
| 202 | + 2013: (JAN, 24), |
| 203 | + 2014: (JAN, 14), |
| 204 | + 2015: ((JAN, 3), (DEC, 23)), |
| 205 | + 2016: (DEC, 12), |
| 206 | + 2017: (DEC, 1), |
| 207 | + 2018: (NOV, 21), |
| 208 | + 2019: (NOV, 9), |
| 209 | + 2020: (OCT, 29), |
| 210 | + 2021: (OCT, 19), |
| 211 | + 2022: (OCT, 8), |
| 212 | + 2023: (SEP, 27), |
| 213 | + 2024: (SEP, 15), |
| 214 | + } |
| 215 | + |
| 216 | + |
| 217 | +class LibyaStaticHolidays: |
| 218 | + """Libya special holidays. |
| 219 | +
|
| 220 | + References: |
| 221 | + * <https://web.archive.org/web/20250629084721/https://lawsociety.ly/legislation/قرار-رقم-555-لسنة-2023-م-بمنح-إجازة-رسمية/> |
| 222 | + """ |
| 223 | + |
| 224 | + special_public_holidays = { |
| 225 | + # Public Holiday. |
| 226 | + 2023: (DEC, 10, tr("عطلة رسمية")) |
| 227 | + } |
0 commit comments