File: switzerland.py

package info (click to toggle)
python-calendra 7.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,600 kB
  • sloc: python: 16,840; makefile: 6
file content (365 lines) | stat: -rw-r--r-- 8,725 bytes parent folder | download | duplicates (2)
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
from datetime import date, timedelta
from ..core import WesternCalendar, SUN
from ..registry_tools import iso_register


@iso_register('CH')
class Switzerland(WesternCalendar):
    'Switzerland'

    # ChristianMixin entries common to (most) cantons - opt out
    include_good_friday = True  # not in TI, VS
    include_easter_sunday = True
    include_easter_monday = True  # not in VS
    include_ascension = True
    include_whit_sunday = True
    include_whit_monday = True  # not in VS
    include_christmas = True
    include_boxing_day = True  # not in GE, NE, VS, VD

    # ChristianMixin entries with varying observance - opt in
    include_epiphany = False
    include_corpus_christi = False
    include_assumption = False
    include_all_saints = False
    include_immaculate_conception = False

    # Swiss entries with varying observance - opt in
    include_berchtolds_day = False
    include_st_josephs_day = False

    FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + (
        (8, 1, "National Holiday"),
    )

    def has_berchtolds_day(self, year):
        return self.include_berchtolds_day

    def get_federal_thanksgiving_monday(self, year):
        "Monday following the 3rd sunday of September"
        third_sunday = self.get_nth_weekday_in_month(year, 9, SUN, 3)
        return (
            third_sunday + timedelta(days=1),
            "Federal Thanksgiving Monday"
        )

    def get_variable_days(self, year):
        days = super().get_variable_days(year)
        if self.has_berchtolds_day(year):
            days.append((date(year, 1, 2), "Berchtold's Day"))
        if self.include_st_josephs_day:
            days.append((date(year, 3, 19), "St Joseph's Day"))
        return days


@iso_register('CH-AG')
class Aargau(Switzerland):
    'Aargau'

    include_berchtolds_day = True
    include_corpus_christi = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-AI')
class AppenzellInnerrhoden(Switzerland):
    'Appenzell Innerrhoden'

    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-AR')
class AppenzellAusserrhoden(Switzerland):
    'Appenzell Ausserrhoden'

    include_labour_day = True


@iso_register('CH-BE')
class Bern(Switzerland):
    'Bern'

    include_berchtolds_day = True


@iso_register('CH-BL')
class BaselLandschaft(Switzerland):
    'Basel-Landschaft'

    include_labour_day = True


@iso_register('CH-BS')
class BaselStadt(Switzerland):
    'Basel-Stadt'

    include_labour_day = True


@iso_register('CH-FR')
class Fribourg(Switzerland):
    'Fribourg'

    include_berchtolds_day = True
    include_labour_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-GE')
class Geneva(Switzerland):
    'Geneva'

    include_boxing_day = False

    FIXED_HOLIDAYS = Switzerland.FIXED_HOLIDAYS + (
        (12, 31, "Creation of Geneva Republic"),
    )

    def get_genevan_fast(self, year):
        "Thursday following the first Sunday of September"
        first_sunday = self.get_nth_weekday_in_month(year, 9, SUN)
        # The following thursday is 4 days after
        return (
            first_sunday + timedelta(days=4),
            "Genevan Fast"
        )

    def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.append(self.get_genevan_fast(year))
        return days


@iso_register('CH-GL')
class Glarus(Switzerland):
    'Glarus (Glaris)'

    include_berchtolds_day = True
    include_all_saints = True

    FIXED_HOLIDAYS = Switzerland.FIXED_HOLIDAYS + (
        (4, 3, "Näfels Ride"),
    )


@iso_register('CH-GR')
class Graubunden(Switzerland):
    'Graubünden (Grisons)'

    include_epiphany = True
    include_st_josephs_day = True
    include_corpus_christi = True
    include_immaculate_conception = True


@iso_register('CH-JU')
class Jura(Switzerland):
    'Jura'

    include_berchtolds_day = True
    include_labour_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_boxing_day = False

    FIXED_HOLIDAYS = Switzerland.FIXED_HOLIDAYS + (
        (6, 23, "Independence Day"),
    )


@iso_register('CH-LU')
class Luzern(Switzerland):
    'Luzern'

    include_berchtolds_day = True
    include_epiphany = True
    include_st_josephs_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-NE')
class Neuchatel(Switzerland):
    'Neuchâtel'

    include_boxing_day = False  # Conditionally added in get_variable_days().
    include_labour_day = True

    FIXED_HOLIDAYS = Switzerland.FIXED_HOLIDAYS + (
        (3, 1, "Republic Day"),
    )

    def has_berchtolds_day(self, year):
        # See https://rsn.ne.ch/DATA/program/books/rsne/pdf/94102.pdf, Art. 3
        if date(year, 1, 1).weekday() == SUN:
            return True
        return False

    def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.append(self.get_federal_thanksgiving_monday(year))
        # See https://rsn.ne.ch/DATA/program/books/rsne/pdf/94102.pdf, Art. 3
        if date(year, 12, 25).weekday() == SUN:
            days.append((date(year, 12, 26), self.boxing_day_label))
        return days


@iso_register('CH-NW')
class Nidwalden(Switzerland):
    'Nidwalden'

    include_st_josephs_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-OW')
class Obwalden(Switzerland):
    'Obwalden'

    include_berchtolds_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True

    FIXED_HOLIDAYS = Switzerland.FIXED_HOLIDAYS + (
        (9, 25, "Saint Nicholas of Flüe Day"),
    )


@iso_register('CH-SG')
class StGallen(Switzerland):
    'St. Gallen'

    include_all_saints = True


@iso_register('CH-SH')
class Schaffhausen(Switzerland):
    'Schaffhausen'

    include_berchtolds_day = True
    include_labour_day = True


@iso_register('CH-SO')
class Solothurn(Switzerland):
    'Solothurn'

    include_berchtolds_day = True
    include_st_josephs_day = True
    include_labour_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-SZ')
class Schwyz(Switzerland):
    'Schwyz'

    include_epiphany = True
    include_st_josephs_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-TG')
class Thurgau(Switzerland):
    'Thurgau'

    include_berchtolds_day = True
    include_labour_day = True


@iso_register('CH-TI')
class Ticino(Switzerland):
    'Ticino'

    include_good_friday = False
    include_epiphany = True
    include_st_josephs_day = True
    include_labour_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True

    FIXED_HOLIDAYS = Switzerland.FIXED_HOLIDAYS + (
        (6, 29, "Saints Peter and Paul"),
    )


@iso_register('CH-UR')
class Uri(Switzerland):
    'Uri'

    include_epiphany = True
    include_st_josephs_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-VD')
class Vaud(Switzerland):
    'Vaud'

    include_berchtolds_day = True
    include_boxing_day = False

    def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.append(self.get_federal_thanksgiving_monday(year))
        return days


@iso_register('CH-VS')
class Valais(Switzerland):
    'Valais'

    include_good_friday = False
    include_easter_monday = False
    include_whit_monday = False
    include_st_josephs_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True
    include_boxing_day = False


@iso_register('CH-ZG')
class Zug(Switzerland):
    'Zug'

    include_berchtolds_day = True
    include_corpus_christi = True
    include_assumption = True
    include_all_saints = True
    include_immaculate_conception = True


@iso_register('CH-ZH')
class Zurich(Switzerland):
    'Zürich'

    include_berchtolds_day = True
    include_labour_day = True