-
Notifications
You must be signed in to change notification settings - Fork 0
/
uk_settlement_calendar.rs
113 lines (112 loc) · 3.26 KB
/
uk_settlement_calendar.rs
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
use cal_calc::{Calendar, Holiday, NthWeek};
use time::{macros::date, Weekday};
fn main() {
// we choose the uk settlement calendar as an example, because of the many exceptions
let uk_settlement_holidays = vec![
// Saturdays
Holiday::WeekDay(Weekday::Saturday),
// Sundays
Holiday::WeekDay(Weekday::Sunday),
// New Year's day
Holiday::MovableYearlyDay {
month: 1,
day: 1,
first: None,
last: None,
},
// Good Friday
Holiday::EasterOffset {
offset: -2,
first: None,
last: None,
},
// Easter Monday
Holiday::EasterOffset {
offset: 1,
first: None,
last: None,
},
// first Monday of May, moved two times in history to 8th of May
Holiday::MonthWeekday {
month: 5,
weekday: Weekday::Monday,
nth: NthWeek::First,
first: None,
last: Some(1994),
},
Holiday::SingularDay(date!(1995-5-8)),
Holiday::MonthWeekday {
month: 5,
weekday: Weekday::Monday,
nth: NthWeek::First,
first: Some(1996),
last: Some(2019),
},
Holiday::SingularDay(date!(2020-5-8)),
Holiday::MonthWeekday {
month: 5,
weekday: Weekday::Monday,
nth: NthWeek::First,
first: Some(2021),
last: None,
},
// last Monday of May (Spring Bank Holiday), has been skipped two times
Holiday::MonthWeekday {
month: 5,
weekday: Weekday::Monday,
nth: NthWeek::Last,
first: None,
last: Some(2001),
},
Holiday::MonthWeekday {
month: 5,
weekday: Weekday::Monday,
nth: NthWeek::Last,
first: Some(2003),
last: Some(2011),
},
Holiday::MonthWeekday {
month: 5,
weekday: Weekday::Monday,
nth: NthWeek::Last,
first: Some(2013),
last: None,
},
// last Monday of August (Summer Bank Holiday)
Holiday::MonthWeekday {
month: 8,
weekday: Weekday::Monday,
nth: NthWeek::Last,
first: None,
last: None,
},
// Christmas
Holiday::MovableYearlyDay {
month: 12,
day: 25,
first: None,
last: None,
},
// Boxing Day
Holiday::MovableYearlyDay {
month: 12,
day: 26,
first: None,
last: None,
},
// Golden Jubilee
Holiday::SingularDay(date!(2002-6-3)),
// Special Spring Holiday
Holiday::SingularDay(date!(2002-6-4)),
// Royal Wedding
Holiday::SingularDay(date!(2011-4-29)),
// Diamond Jubilee
Holiday::SingularDay(date!(2012-6-4)),
// Special Spring Holiday
Holiday::SingularDay(date!(2012-6-5)),
// Introduction of EUR
Holiday::SingularDay(date!(1999-12-31)),
];
let uk_cal = Calendar::calc_calendar(&uk_settlement_holidays, 1999, 2020);
println!("{:#?}", uk_cal);
}