File tree 2 files changed +258
-0
lines changed
2 files changed +258
-0
lines changed Original file line number Diff line number Diff line change 60
60
SE : ['se.yaml']
61
61
TN : ['tn.yaml']
62
62
TR : ['tr.yaml']
63
+ TSX : ['tsx.yaml']
63
64
UA : ['ua.yaml']
64
65
US : ['us.yaml', 'northamericainformal.yaml']
65
66
UnitedNations : ['unitednations.yaml']
Original file line number Diff line number Diff line change
1
+ # Toronto Stock Exchange (TSX)'s holiday definitions for the Ruby Holiday gem.
2
+ #
3
+ # Source: https://www.tsx.com/trading/calendars-and-trading-hours/calendar
4
+ ---
5
+ months :
6
+ 0 :
7
+ - name : Good Friday
8
+ regions : [tsx]
9
+ function : easter(year)
10
+ function_modifier : -2
11
+ 1 :
12
+ - name : New Year's Day
13
+ regions : [tsx]
14
+ mday : 1
15
+ observed : to_monday_if_weekend(date)
16
+ 2 :
17
+ - name : Family Day
18
+ regions : [tsx]
19
+ wday : 1
20
+ week : 3
21
+ year_ranges :
22
+ from : 2008
23
+ 5 :
24
+ - name : Victoria Day
25
+ regions : [tsx]
26
+ function : ca_victoria_day(year)
27
+ 7 :
28
+ - name : Canada Day
29
+ regions : [tsx]
30
+ mday : 1
31
+ observed : to_monday_if_weekend(date)
32
+ 8 :
33
+ - name : Civic Holiday
34
+ week : 1
35
+ regions : [tsx]
36
+ wday : 1
37
+ 9 :
38
+ - name : Labour Day
39
+ week : 1
40
+ regions : [tsx]
41
+ wday : 1
42
+ 10 :
43
+ - name : Thanksgiving
44
+ week : 2
45
+ regions : [tsx]
46
+ wday : 1
47
+ 12 :
48
+ - name : Christmas Day
49
+ regions : [tsx]
50
+ mday : 25
51
+ year_ranges :
52
+ until : 2020
53
+ observed : to_weekday_if_weekend(date)
54
+ - name : Christmas Day
55
+ regions : [tsx]
56
+ mday : 25
57
+ observed : to_monday_if_weekend(date)
58
+ year_ranges :
59
+ from : 2020
60
+ - name : Boxing Day
61
+ regions : [tsx]
62
+ mday : 26
63
+ year_ranges :
64
+ until : 2020
65
+ observed : to_monday_if_weekend(date)
66
+ - name : Boxing Day
67
+ regions : [tsx]
68
+ mday : 26
69
+ year_ranges :
70
+ from : 2020
71
+ observed : to_weekday_if_boxing_weekend(date)
72
+
73
+ methods :
74
+ ca_victoria_day :
75
+ # Monday on or before May 24
76
+ arguments : year
77
+ ruby : |
78
+ date = Date.civil(year,5,24)
79
+ if date.wday > 1
80
+ date -= (date.wday - 1)
81
+ elsif date.wday == 0
82
+ date -= 6
83
+ end
84
+ date
85
+
86
+ tests :
87
+ - given :
88
+ date : ' 2008-01-01'
89
+ regions : ["tsx"]
90
+ options : ["informal"]
91
+ expect :
92
+ name : " New Year's Day"
93
+ - given :
94
+ date : ' 2008-03-21'
95
+ regions : ["tsx"]
96
+ options : ["informal"]
97
+ expect :
98
+ name : " Good Friday"
99
+ - given :
100
+ date : ' 2008-07-01'
101
+ regions : ["tsx"]
102
+ options : ["informal"]
103
+ expect :
104
+ name : " Canada Day"
105
+ - given :
106
+ date : ' 2008-09-01'
107
+ regions : ["tsx"]
108
+ options : ["informal"]
109
+ expect :
110
+ name : " Labour Day"
111
+ - given :
112
+ date : ' 2008-12-25'
113
+ regions : ["tsx"]
114
+ options : ["informal"]
115
+ expect :
116
+ name : " Christmas Day"
117
+
118
+ # Family Day in Ontario - should not be active before 2008
119
+ - given :
120
+ date : ' 1970-02-16'
121
+ regions : ["tsx"]
122
+ expect :
123
+ holiday : false
124
+ - given :
125
+ date : ' 1988-02-15'
126
+ regions : ["tsx"]
127
+ expect :
128
+ holiday : false
129
+ - given :
130
+ date : ' 1989-02-20'
131
+ regions : ["tsx"]
132
+ expect :
133
+ holiday : false
134
+ - given :
135
+ date : ' 2006-02-20'
136
+ regions : ["tsx"]
137
+ expect :
138
+ holiday : false
139
+ - given :
140
+ date : ' 2007-02-19'
141
+ regions : ["tsx"]
142
+ expect :
143
+ holiday : false
144
+
145
+ # New years observed date
146
+ - given :
147
+ date : ' 2011-01-03'
148
+ regions : ["tsx"]
149
+ options : ["observed"]
150
+ expect :
151
+ name : " New Year's Day"
152
+ - given :
153
+ date : ' 2012-01-02'
154
+ regions : ["tsx"]
155
+ options : ["observed"]
156
+ expect :
157
+ name : " New Year's Day"
158
+ - given :
159
+ date : ' 2016-01-01'
160
+ regions : ["tsx"]
161
+ options : ["observed"]
162
+ expect :
163
+ name : " New Year's Day"
164
+
165
+ # Canada Day observed date
166
+ - given :
167
+ date : ' 2011-07-01'
168
+ regions : ["tsx"]
169
+ options : ["observed"]
170
+ expect :
171
+ name : " Canada Day"
172
+ - given :
173
+ date : ' 2012-07-02'
174
+ regions : ["tsx"]
175
+ options : ["observed"]
176
+ expect :
177
+ name : " Canada Day"
178
+ - given :
179
+ date : ' 2017-07-03'
180
+ regions : ["tsx"]
181
+ options : ["observed"]
182
+ expect :
183
+ name : " Canada Day"
184
+
185
+ # Christmas Day
186
+ - given :
187
+ date : ' 2010-12-25'
188
+ regions : ["tsx"]
189
+ expect :
190
+ name : " Christmas Day"
191
+ - given :
192
+ date : ' 2018-12-25'
193
+ regions : ["tsx"]
194
+ expect :
195
+ name : " Christmas Day"
196
+ - given :
197
+ date : ' 2022-12-25'
198
+ regions : ["tsx"]
199
+ expect :
200
+ name : " Christmas Day"
201
+ - given :
202
+ date : ' 2022-12-25'
203
+ regions : ["tsx"]
204
+ options : ["observed"]
205
+ expect :
206
+ holiday : false
207
+
208
+ # Christmas Day observed date
209
+ - given :
210
+ date : ' 2010-12-24'
211
+ regions : ["tsx"]
212
+ options : ["observed"]
213
+ expect :
214
+ name : " Christmas Day"
215
+ - given :
216
+ date : ' 2012-12-25'
217
+ regions : ["tsx"]
218
+ options : ["observed"]
219
+ expect :
220
+ name : " Christmas Day"
221
+ - given :
222
+ date : ' 2016-12-26'
223
+ regions : ["tsx"]
224
+ options : ["observed"]
225
+ expect :
226
+ name : " Christmas Day"
227
+ - given :
228
+ date : ' 2021-12-27'
229
+ regions : [ "tsx" ]
230
+ options : [ "observed" ]
231
+ expect :
232
+ name : " Christmas Day"
233
+ - given :
234
+ date : ' 2022-12-26'
235
+ regions : ["tsx"]
236
+ options : ["observed"]
237
+ expect :
238
+ name : " Christmas Day"
239
+
240
+ - given :
241
+ date : ['2010-12-27', '2012-12-26', '2015-12-28']
242
+ regions : ["tsx"]
243
+ options : ["observed"]
244
+ expect :
245
+ name : " Boxing Day"
246
+
247
+ - given :
248
+ date : ['2022-05-23', '2021-05-24']
249
+ regions : ['tsx']
250
+ expect :
251
+ name : " Victoria Day"
252
+ - given :
253
+ date : ' 2015-05-24'
254
+ regions : ["tsx"]
255
+ options : ["observed"]
256
+ expect :
257
+ holiday : false
You can’t perform that action at this time.
0 commit comments