File: afghanistan.py

package info (click to toggle)
python-holidays 0.90-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 59,088 kB
  • sloc: python: 121,956; javascript: 85; makefile: 62
file content (171 lines) | stat: -rw-r--r-- 5,482 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#  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 CONTRIBUTORS file)
#           dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023
#           ryanss <ryanssdev@icloud.com> (c) 2014-2017
#  Website: https://github.com/vacanza/holidays
#  License: MIT (see LICENSE file)

from gettext import gettext as tr

from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import JAN, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC, FRI, SAT
from holidays.groups import InternationalHolidays, IslamicHolidays, PersianCalendarHolidays
from holidays.holiday_base import HolidayBase


class Afghanistan(HolidayBase, InternationalHolidays, IslamicHolidays, PersianCalendarHolidays):
    """Afghanistan holidays.

    References:
        * <https://en.wikipedia.org/wiki/Public_holidays_in_Afghanistan>
        * <https://web.archive.org/web/20250903162748/https://www.timeanddate.com/holidays/afghanistan>
        * <https://en.wikipedia.org/wiki/Workweek_and_weekend>
    """

    country = "AF"
    default_language = "fa_AF"
    # %s (estimated).
    estimated_label = tr("%s (برآورد شده)")
    supported_languages = ("en_US", "fa_AF", "ps_AF")
    # Afghanistan's regaining of full independence from British influence.
    start_year = 1919
    weekend = {FRI, SAT}

    def __init__(self, *args, islamic_show_estimated: bool = True, **kwargs):
        """
        Args:
            islamic_show_estimated:
                Whether to add "estimated" label to Islamic holidays name
                if holiday date is estimated.
        """
        InternationalHolidays.__init__(self)
        IslamicHolidays.__init__(
            self, cls=AfghanistanIslamicHolidays, show_estimated=islamic_show_estimated
        )
        PersianCalendarHolidays.__init__(self)
        super().__init__(*args, **kwargs)

    def _populate_public_holidays(self):
        if self._year >= 1989:
            # Liberation Day.
            self._add_holiday_feb_15(tr("روز آزادی"))

        # Afghanistan Independence Day.
        self._add_holiday_aug_19(tr("روز استقلال افغانستان"))

        if self._year <= 1996 or 2001 <= self._year <= 2020:
            # Nowruz.
            self._add_nowruz_day(tr("نوروز"))

        if self._year >= 1992:
            # Mojahedin's Victory Day.
            self._add_holiday_apr_28(tr("روز پیروزی مجاهدین"))

        if 1974 <= self._year <= 1996 or 2002 <= self._year <= 2021:
            # International Workers' Day.
            self._add_labor_day(tr("روز جهانی کارگر"))

        if 1978 <= self._year <= 1988:
            # Soviet Victory Day.
            self._add_holiday_may_9(tr("روز پیروزی شوروی"))

        if self._year >= 2022:
            # Islamic Emirate Victory Day.
            self._add_islamic_emirat_victory_day(tr("روز پیروزی امارت اسلامی"))

            # American Withdrawal Day.
            self._add_holiday_aug_31(tr("روز خروج آمریکایی ها"))

        if 2012 <= self._year <= 2020:
            # Martyrs' Day.
            self._add_holiday_sep_9(tr("روز شهیدان"))

        if self._year <= 2021:
            # Ashura.
            self._add_ashura_day(tr("عاشورا"))

        # Prophet's Birthday.
        self._add_mawlid_day(tr("میلاد پیامبر"))

        # First Day of Ramadan.
        self._add_ramadan_beginning_day(tr("اول رمضان"))

        # Eid al-Fitr.
        name = tr("عید فطر")
        self._add_eid_al_fitr_day(name)
        self._add_eid_al_fitr_day_two(name)
        self._add_eid_al_fitr_day_three(name)

        # Day of Arafah.
        self._add_arafah_day(tr("روز عرفه"))

        # Eid al-Adha.
        name = tr("عید قربانی")
        self._add_eid_al_adha_day(name)
        self._add_eid_al_adha_day_two(name)
        self._add_eid_al_adha_day_three(name)


class AF(Afghanistan):
    pass


class AFG(Afghanistan):
    pass


class AfghanistanIslamicHolidays(_CustomIslamicHolidays):
    ASHURA_DATES_CONFIRMED_YEARS = (2014, 2021)
    ASHURA_DATES = {
        2015: (OCT, 24),
        2016: (OCT, 12),
        2017: (OCT, 1),
        2018: (SEP, 21),
        2019: (SEP, 10),
        2020: (AUG, 30),
        2021: (AUG, 19),
    }

    EID_AL_ADHA_DATES_CONFIRMED_YEARS = (2014, 2025)
    EID_AL_ADHA_DATES = {
        2014: (OCT, 5),
        2016: (SEP, 13),
        2017: (SEP, 2),
        2018: (AUG, 22),
        2024: (JUN, 17),
        2025: (JUN, 7),
    }

    EID_AL_FITR_DATES_CONFIRMED_YEARS = (2014, 2025)
    EID_AL_FITR_DATES = {
        2014: (JUL, 29),
        2015: (JUL, 18),
        2016: (JUL, 7),
        2017: (JUN, 26),
        2022: (MAY, 1),
        2023: (APR, 22),
    }

    MAWLID_DATES_CONFIRMED_YEARS = (2014, 2025)
    MAWLID_DATES = {
        2014: (JAN, 14),
        2015: ((JAN, 3), (DEC, 24)),
        2016: (DEC, 12),
        2017: (DEC, 1),
        2018: (NOV, 21),
        2019: (NOV, 10),
        2021: (OCT, 19),
        2024: (SEP, 16),
        2025: (SEP, 5),
    }

    RAMADAN_BEGINNING_DATES_CONFIRMED_YEARS = (2014, 2025)
    RAMADAN_BEGINNING_DATES = {
        2014: (JUN, 29),
        2016: (JUN, 7),
    }