forked from rickar/cal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathholiday_defs_be.go
47 lines (42 loc) · 1.34 KB
/
holiday_defs_be.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
package cal
import "time"
// Holidays in Belgium
var (
BENieuwjaar = NewYear
BEPaasmaandag = EasterMonday
BEDagVanDeArbeid = ECBLabourDay
BEOnzeLieveHeerHemelvaart = NewHolidayFunc(calculateOnzeLieveHeerHemelvaart)
BEPinkstermaandag = NewHolidayFunc(calculatePinkstermaandag)
BENationaleFeestdag = NewHoliday(time.July, 21)
BEOnzeLieveVrouwHemelvaart = NewHoliday(time.August, 15)
BEAllerheiligen = NewHoliday(time.November, 1)
BEWapenstilstand = NewHoliday(time.November, 11)
BEKerstmis = Christmas
)
// AddBelgiumHolidays adds all Belgium holidays to the Calendar
func AddBelgiumHolidays(c *Calendar) {
c.AddHoliday(
BENieuwjaar,
BEPaasmaandag,
BEDagVanDeArbeid,
BEOnzeLieveHeerHemelvaart,
BEPinkstermaandag,
BENationaleFeestdag,
BEOnzeLieveVrouwHemelvaart,
BEAllerheiligen,
BEWapenstilstand,
BEKerstmis,
)
}
func calculateOnzeLieveHeerHemelvaart(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 39 days after Easter Sunday
t := easter.AddDate(0, 0, +39)
return t.Month(), t.Day()
}
func calculatePinkstermaandag(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 50 days after Easter Sunday
t := easter.AddDate(0, 0, +50)
return t.Month(), t.Day()
}