forked from rickar/cal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
holiday_defs_de.go
173 lines (161 loc) · 4.56 KB
/
holiday_defs_de.go
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
// (c) 2014 Rick Arnold. Licensed under the BSD license (see LICENSE).
package cal
import "time"
// Holidays in Germany
var (
DENeujahr = NewYear
DEHeiligeDreiKoenige = NewHoliday(time.January, 6)
DEInternationalerFrauentag = NewHoliday(time.March, 8)
DEKarFreitag = GoodFriday
DEOstersonntag = NewHolidayFunc(calculateOstersonntag)
DEOstermontag = EasterMonday
DETagderArbeit = NewHoliday(time.May, 1)
DEChristiHimmelfahrt = NewHolidayFunc(calculateHimmelfahrt)
DEPfingstsonntag = NewHolidayFunc(calculatePfingstSonntag)
DEPfingstmontag = NewHolidayFunc(calculatePfingstMontag)
DEFronleichnam = NewHolidayFunc(calculateFronleichnam)
DEMariaHimmelfahrt = NewHoliday(time.August, 15)
DEWeltkindertag = NewHoliday(time.September, 20)
DETagderDeutschenEinheit = NewHoliday(time.October, 3)
DEReformationstag = NewHoliday(time.October, 31)
DEReformationstag2017 = NewHolidayExact(time.October, 31, 2017)
DEAllerheiligen = NewHoliday(time.November, 1)
DEBußUndBettag = NewHolidayFunc(calculateBußUndBettag)
DEErsterWeihnachtstag = Christmas
DEZweiterWeihnachtstag = Christmas2
)
// AddGermanHolidays adds all German holidays to the Calendar
func AddGermanHolidays(c *Calendar) {
c.AddHoliday(
DENeujahr,
DEKarFreitag,
DEOstermontag,
DETagderArbeit,
DEChristiHimmelfahrt,
DEPfingstmontag,
DETagderDeutschenEinheit,
DEErsterWeihnachtstag,
DEZweiterWeihnachtstag,
)
}
// AddGermanyStateHolidays adds german state holidays to the calendar
func AddGermanyStateHolidays(c *Calendar, state string) {
switch state {
case "BB": // Brandenburg
c.AddHoliday(
DEOstersonntag,
DEPfingstsonntag,
DEReformationstag,
)
case "BE": // Berlin
c.AddHoliday(
DEInternationalerFrauentag,
DEReformationstag2017,
)
case "BW": // Baden-Württemberg
c.AddHoliday(
DEHeiligeDreiKoenige,
DEFronleichnam,
DEAllerheiligen,
DEReformationstag2017,
)
case "BY": // Bayern
c.AddHoliday(
DEHeiligeDreiKoenige,
DEFronleichnam,
DEMariaHimmelfahrt,
DEAllerheiligen,
DEReformationstag2017,
)
case "HB": // Bremen
c.AddHoliday(DEReformationstag)
case "HE": // Hessen
c.AddHoliday(
DEOstersonntag,
DEPfingstsonntag,
DEFronleichnam,
DEReformationstag2017,
)
case "HH": // Hamburg
c.AddHoliday(DEReformationstag)
case "MV": // Mecklenburg-Vorpommern
c.AddHoliday(DEReformationstag)
case "NI": // Niedersachsen
c.AddHoliday(DEReformationstag)
case "NW": // Nordrhein-Westfalen
c.AddHoliday(
DEFronleichnam,
DEAllerheiligen,
DEReformationstag2017,
)
case "RP": // Rheinland-Pfalz
c.AddHoliday(
DEFronleichnam,
DEAllerheiligen,
DEReformationstag2017,
)
case "SN", "SA": // Sachsen (keep wrong "SA" code for compatibility)
c.AddHoliday(
DEReformationstag,
DEBußUndBettag,
)
case "SH": // Schleswig-Holstein
c.AddHoliday(DEReformationstag)
case "SL": // Saarland
c.AddHoliday(
DEFronleichnam,
DEMariaHimmelfahrt,
DEAllerheiligen,
DEReformationstag2017,
)
case "ST": // Sachen-Anhalt
c.AddHoliday(
DEHeiligeDreiKoenige,
DEReformationstag,
)
case "TH": // Thüringen
c.AddHoliday(
DEWeltkindertag,
DEReformationstag,
)
}
}
func calculateOstersonntag(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
return easter.Month(), easter.Day()
}
func calculateHimmelfahrt(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 39 days after Easter Sunday
em := easter.AddDate(0, 0, +39)
return em.Month(), em.Day()
}
func calculatePfingstSonntag(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 50 days after Easter Sunday
em := easter.AddDate(0, 0, +49)
return em.Month(), em.Day()
}
func calculatePfingstMontag(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 50 days after Easter Sunday
em := easter.AddDate(0, 0, +50)
return em.Month(), em.Day()
}
func calculateFronleichnam(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 50 days after Easter Sunday
em := easter.AddDate(0, 0, +60)
return em.Month(), em.Day()
}
func calculateBußUndBettag(year int, loc *time.Location) (time.Month, int) {
t := time.Date(year, 11, 23, 0, 0, 0, 0, loc)
for i := -1; i > -10; i-- {
d := t.Add(time.Hour * 24 * time.Duration(i))
if d.Weekday() == time.Wednesday {
t = d
break
}
}
return t.Month(), t.Day()
}