File: germany.py

package info (click to toggle)
python-holidays 0.86-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,296 kB
  • sloc: python: 117,830; javascript: 85; makefile: 59
file content (318 lines) | stat: -rw-r--r-- 10,770 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#  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.gregorian import MAY, JUN, OCT
from holidays.constants import CATHOLIC, PUBLIC
from holidays.groups import ChristianHolidays, InternationalHolidays, StaticHolidays
from holidays.holiday_base import HolidayBase


class Germany(HolidayBase, ChristianHolidays, InternationalHolidays, StaticHolidays):
    """Germany holidays.

    This class doesn't return any holidays before 1990-10-03.

    Before that date the current Germany was separated into the "German Democratic
    Republic" and the "Federal Republic of Germany" which both had somewhat
    different holidays. Since this class is called "Germany" it doesn't really
     make sense to include the days from the two former countries.

    "Mariä Himmelfahrt" is only a holiday in Bavaria (BY) and "Fronleichnam"
    in Saxony (SN) and Thuringia (TH) if municipality is mostly catholic which
    in term depends on census data. It's listed in "CATHOLIC" category for these provinces.

    References:
        * <https://en.wikipedia.org/wiki/Public_holidays_in_Germany>
        * [Bavaria's Feiertagsgesetz](https://web.archive.org/web/20250724092008/https://www.gesetze-bayern.de/Content/Document/BayFTG-1)
    """

    country = "DE"
    default_language = "de"
    start_year = 1990
    subdivisions = (
        # States.
        "BB",  # Brandenburg.
        "BE",  # Berlin.
        "BW",  # Baden-Württemberg.
        "BY",  # Bayern.
        "HB",  # Bremen.
        "HE",  # Hessen.
        "HH",  # Hamburg.
        "MV",  # Mecklenburg-Vorpommern.
        "NI",  # Niedersachsen.
        "NW",  # Nordrhein-Westfalen.
        "RP",  # Rheinland-Pfalz.
        "SH",  # Schleswig-Holstein.
        "SL",  # Saarland.
        "SN",  # Sachsen.
        "ST",  # Sachsen-Anhalt.
        "TH",  # Thüringen.
        # Cities.
        "Augsburg",
    )
    subdivisions_aliases = {
        "Brandenburg": "BB",
        "Berlin": "BE",
        "Baden-Württemberg": "BW",
        "Bayern": "BY",
        "Bremen": "HB",
        "Hessen": "HE",
        "Hamburg": "HH",
        "Mecklenburg-Vorpommern": "MV",
        "Niedersachsen": "NI",
        "Nordrhein-Westfalen": "NW",
        "Rheinland-Pfalz": "RP",
        "Schleswig-Holstein": "SH",
        "Saarland": "SL",
        "Sachsen": "SN",
        "Sachsen-Anhalt": "ST",
        "Thüringen": "TH",
    }
    supported_categories = (CATHOLIC, PUBLIC)
    supported_languages = ("de", "en_US", "th", "uk")
    _deprecated_subdivisions = ("BYP",)

    def __init__(self, *args, **kwargs) -> None:
        ChristianHolidays.__init__(self)
        InternationalHolidays.__init__(self)
        StaticHolidays.__init__(self, GermanyStaticHolidays)
        super().__init__(*args, **kwargs)

    def _populate_public_holidays(self):
        if self._year >= 1991:
            # New Year's Day.
            self._add_new_years_day(tr("Neujahr"))

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

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

            # Labor Day.
            self._add_labor_day(tr("Erster Mai"))

            # Ascension Day.
            self._add_ascension_thursday(tr("Christi Himmelfahrt"))

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

        # German Unity Day.
        self._add_holiday_oct_3(tr("Tag der Deutschen Einheit"))

        if self._year <= 1994:
            # Repentance and Prayer Day.
            self._add_holiday_1st_wed_before_nov_22(tr("Buß- und Bettag"))

        # Christmas Day.
        self._add_christmas_day(tr("Erster Weihnachtstag"))

        # Second Day of Christmas.
        self._add_christmas_day_two(tr("Zweiter Weihnachtstag"))

        if self.subdiv == "BYP":
            self._populate_subdiv_by_public_holidays()

    def _populate_subdiv_bb_public_holidays(self):
        if self._year >= 1991:
            # Easter Sunday.
            self._add_easter_sunday(tr("Ostersonntag"))

            # Whit Sunday.
            self._add_whit_sunday(tr("Pfingstsonntag"))

        # Reformation Day.
        self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_be_public_holidays(self):
        if self._year >= 2019:
            # International Women's Day.
            self._add_womens_day(tr("Internationaler Frauentag"))

    def _populate_subdiv_bw_public_holidays(self):
        if self._year >= 1991:
            # Epiphany.
            self._add_epiphany_day(tr("Heilige Drei Könige"))

            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

        # All Saints' Day.
        self._add_all_saints_day(tr("Allerheiligen"))

    def _populate_subdiv_by_public_holidays(self):
        if self._year >= 1991:
            # Epiphany.
            self._add_epiphany_day(tr("Heilige Drei Könige"))

            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

        # All Saints' Day.
        self._add_all_saints_day(tr("Allerheiligen"))

    def _populate_subdiv_by_catholic_holidays(self):
        if self._year >= 1991:
            # Assumption Day.
            self._add_assumption_of_mary_day(tr("Mariä Himmelfahrt"))

    def _populate_subdiv_hb_public_holidays(self):
        if self._year >= 2018:
            # Reformation Day.
            self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_he_public_holidays(self):
        if self._year >= 1991:
            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

    def _populate_subdiv_hh_public_holidays(self):
        if self._year >= 2018:
            # Reformation Day.
            self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_mv_public_holidays(self):
        if self._year >= 2023:
            # International Women's Day.
            self._add_womens_day(tr("Internationaler Frauentag"))

        # Reformation Day.
        self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_ni_public_holidays(self):
        if self._year >= 2018:
            # Reformation Day.
            self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_nw_public_holidays(self):
        if self._year >= 1991:
            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

        # All Saints' Day.
        self._add_all_saints_day(tr("Allerheiligen"))

    def _populate_subdiv_rp_public_holidays(self):
        if self._year >= 1991:
            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

        # All Saints' Day.
        self._add_all_saints_day(tr("Allerheiligen"))

    def _populate_subdiv_sh_public_holidays(self):
        if self._year >= 2018:
            # Reformation Day.
            self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_sl_public_holidays(self):
        if self._year >= 1991:
            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

            # Assumption Day.
            self._add_assumption_of_mary_day(tr("Mariä Himmelfahrt"))

        # All Saints' Day.
        self._add_all_saints_day(tr("Allerheiligen"))

    def _populate_subdiv_sn_public_holidays(self):
        # Reformation Day.
        self._add_holiday_oct_31(tr("Reformationstag"))

        if self._year >= 1995:
            # Repentance and Prayer Day.
            self._add_holiday_1st_wed_before_nov_22(tr("Buß- und Bettag"))

    def _populate_subdiv_sn_catholic_holidays(self):
        if self._year >= 1991:
            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

    def _populate_subdiv_st_public_holidays(self):
        if self._year >= 1991:
            # Epiphany.
            self._add_epiphany_day(tr("Heilige Drei Könige"))

        # Reformation Day.
        self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_th_public_holidays(self):
        if self._year >= 2019:
            # World Children's Day.
            self._add_holiday_sep_20(tr("Weltkindertag"))

        # Reformation Day.
        self._add_holiday_oct_31(tr("Reformationstag"))

    def _populate_subdiv_th_catholic_holidays(self):
        if self._year >= 1991:
            # Corpus Christi.
            self._add_corpus_christi_day(tr("Fronleichnam"))

    def _populate_subdiv_augsburg_public_holidays(self):
        self._populate_subdiv_by_public_holidays()

        if self._year >= 1991:
            # Augsburg Peace Festival.
            self._add_holiday_aug_8(tr("Augsburger Hohes Friedensfest"))


class DE(Germany):
    pass


class DEU(Germany):
    pass


class GermanyStaticHolidays:
    """Germany special holidays.

    References:
        * <https://web.archive.org/web/20241127055605/https://www.stuttgarter-zeitung.de/inhalt.reformationstag-2017-einmalig-bundesweiter-feiertag.b7e189b3-a33d-41a3-a0f4-141cd13df54e.html>
        * <https://web.archive.org/web/20250415233518/https://www.bbc.com/news/world-europe-52574748>
        * <https://web.archive.org/web/20241219151307/https://gesetze.berlin.de/bsbe/document/jlr-FeiertGBEV8P1>
    """

    special_public_holidays = {
        # Reformation Day.
        2017: (OCT, 31, tr("Reformationstag")),
    }

    special_be_public_holidays = {
        2020: (
            MAY,
            8,
            # 75th anniversary of the liberation from Nazism and
            # the end of the Second World War in Europe.
            tr(
                "75. Jahrestag der Befreiung vom Nationalsozialismus "
                "und der Beendigung des Zweiten Weltkriegs in Europa"
            ),
        ),
        2025: (
            MAY,
            8,
            # 80th anniversary of the liberation from Nazism and
            # the end of the Second World War in Europe.
            tr(
                "80. Jahrestag der Befreiung vom Nationalsozialismus "
                "und der Beendigung des Zweiten Weltkriegs in Europa"
            ),
        ),
        # 75th anniversary of the East German uprising of 1953.
        2028: (JUN, 17, tr("75. Jahrestag des Aufstandes vom 17. Juni 1953")),
    }