forked from rickar/cal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathholiday_defs_de.go
More file actions
154 lines (142 loc) · 3.98 KB
/
holiday_defs_de.go
File metadata and controls
154 lines (142 loc) · 3.98 KB
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
// (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)
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)
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 "BW": // Baden-Württemberg
c.AddHoliday(
DEHeiligeDreiKoenige,
DEFronleichnam,
DEAllerheiligen,
DEReformationstag2017,
)
case "BY": // Bayern
c.AddHoliday(
DEHeiligeDreiKoenige,
DEFronleichnam,
DEMariaHimmelfahrt,
DEAllerheiligen,
DEReformationstag2017,
)
case "HE": // Hessen
c.AddHoliday(DEFronleichnam)
case "MV": // Mecklenburg-Vorpommern
c.AddHoliday(DEReformationstag)
case "NW": // Nordrhein-Westfalen
c.AddHoliday(
DEFronleichnam,
DEAllerheiligen,
DEReformationstag2017,
)
case "RP": // Rheinland-Pfalz
c.AddHoliday(
DEFronleichnam,
DEAllerheiligen,
DEReformationstag2017,
)
case "SA": // Sachsen
c.AddHoliday(
DEFronleichnam,
DEReformationstag,
DEBußUndBettag,
)
case "SL": // Saarland
c.AddHoliday(
DEFronleichnam,
DEAllerheiligen,
DEMariaHimmelfahrt,
DEReformationstag2017,
)
case "ST": // Sachen-Anhalt
c.AddHoliday(
DEHeiligeDreiKoenige,
DEReformationstag,
)
case "TH": // Thüringen
c.AddHoliday(
DEFronleichnam,
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()
}