File: iceland.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 (44 lines) | stat: -rw-r--r-- 1,329 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
from datetime import date
from ..core import WesternCalendar, THU, MON
from ..registry_tools import iso_register


@iso_register('IS')
class Iceland(WesternCalendar):
    'Iceland'

    # Christian holidays
    include_holy_thursday = True
    include_good_friday = True
    include_easter_monday = True
    include_ascension = True
    include_whit_monday = True
    include_christmas_eve = True
    include_boxing_day = True
    boxing_day_label = "St Stephen's Day"

    # Civil holidays
    include_labour_day = True
    FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + (
        (6, 17, "Icelandic National Day"),
        (12, 31, "New Year's Eve"),
    )

    def get_first_day_of_summer(self, year):
        """It's the first thursday *after* April, 18th.
        If April the 18th is a thursday, then it jumps to the 24th.
        """
        return Iceland.get_nth_weekday_in_month(
            year, 4, THU,
            start=date(year, 4, 19))

    def get_commerce_day(self, year):
        return Iceland.get_nth_weekday_in_month(year, 8, MON)

    def get_variable_days(self, year):
        days = super().get_variable_days(year)
        days.extend([
            (self.get_first_day_of_summer(year), "First day of summer"),
            (self.get_commerce_day(year), "Commerce Day"),
        ])
        return days