forked from rickar/cal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
holiday_defs_pl.go
61 lines (54 loc) · 1.73 KB
/
holiday_defs_pl.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
package cal
import (
"time"
)
// Poland holidays
var (
PLNewYear = NewYear
PLThreeKings = NewHoliday(time.January, 6)
PLEasterMonday = EasterMonday
PLEasterSunday = NewHolidayFunc(calculateEasterSunday)
PLLabourDay = NewHoliday(time.May, 1)
PLNationalDay = NewHoliday(time.May, 3)
PLPentecostDay = NewHolidayFunc(calculatePentecostDay)
PLCorpusChristi = NewHolidayFunc(calculateCorpusChristiDay)
PLAssumptionBlessedVirginMary = NewHoliday(time.August, 15)
PLAllSaints = NewHoliday(time.November, 1)
PLNationalIndependenceDay = NewHoliday(time.November, 11)
PLChristmasDayOne = Christmas
PLChristmasDayTwo = Christmas2
)
// AddPolandHolidays adds all Poland holidays to the Calendar
func AddPolandHolidays(c *Calendar) {
c.AddHoliday(
PLNewYear,
PLThreeKings,
PLEasterMonday,
PLEasterSunday,
PLLabourDay,
PLNationalDay,
PLPentecostDay,
PLCorpusChristi,
PLAssumptionBlessedVirginMary,
PLAllSaints,
PLNationalIndependenceDay,
PLChristmasDayOne,
PLChristmasDayTwo,
)
}
func calculateEasterSunday(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
return easter.Month(), easter.Day()
}
func calculatePentecostDay(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 calculateCorpusChristiDay(year int, loc *time.Location) (time.Month, int) {
easter := calculateEaster(year, loc)
// 60 days after Easter Sunday
em := easter.AddDate(0, 0, +60)
return em.Month(), em.Day()
}