-
Notifications
You must be signed in to change notification settings - Fork 136
/
nz.yaml
346 lines (343 loc) · 7.93 KB
/
nz.yaml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# New Zealand holiday definitions for the Ruby Holiday gem.
# Updated: 2010-03-28.
# Sources:
# - http://en.wikipedia.org/wiki/Public_holidays_in_New_Zealand
# - Matariki https://www.mbie.govt.nz/business-and-employment/employment-and-skills/employment-legislation-reviews/matariki/matariki-public-holiday/
---
months:
0:
- name: Good Friday
regions: [nz]
function: easter(year)
function_modifier: -2
- name: Easter Monday
regions: [nz]
function: easter(year)
function_modifier: 1
- name: Matariki
regions: [nz]
function: matariki(year)
1:
- name: New Year's Day
regions: [nz]
mday: 1
observed: to_monday_if_weekend(date)
- name: Day after New Year's Day
regions: [nz]
mday: 2
observed: to_weekday_if_boxing_weekend(date)
- name: Southland Anniversary Day
regions: [nz_sl]
mday: 17
- name: Wellington Anniversary Day
regions: [nz_we]
mday: 22
observed: closest_monday(date)
- name: Auckland Anniversary Day
regions: [nz_ak]
mday: 29
observed: closest_monday(date)
- name: Northland Anniversary Day
regions: [nz_nl]
mday: 29
observed: closest_monday(date)
2:
- name: Nelson Anniversary Day
regions: [nz_ne]
mday: 1
observed: closest_monday(date)
- name: Waitangi Day
regions: [nz]
mday: 6
observed: to_monday_if_weekend(date)
3:
- name: Otago Anniversary Day
regions: [nz_ot]
mday: 23
observed: closest_monday(date)
- name: Taranaki Anniversary Day
regions: [nz_ta]
week: 2
wday: 1
observed: closest_monday(date)
4:
- name: ANZAC Day
regions: [nz]
mday: 25
observed: to_monday_if_weekend(date)
6:
- name: Queen's Birthday
regions: [nz]
week: 1
wday: 1
year_ranges:
until: 2022
- name: King's Birthday
regions: [nz]
week: 1
wday: 1
year_ranges:
from: 2023
9:
- name: Dominion Day
regions: [nz_sc]
week: 4
wday: 1
10:
- name: Hawke's bay Anniversary Day
regions: [nz_hb]
week: 1
wday: 1
observed: previous_friday(date)
- name: Labour Day
regions: [nz]
week: 4
wday: 1
- name: Marlborough Anniversary Day
regions: [nz_mb]
week: 4
wday: 1
observed: next_week(date)
11:
- name: Canterbury Anniversary Day
regions: [nz_ca]
week: 2
wday: 5
- name: Chatham Island Anniversary Day
regions: [nz_ch]
mday: 30
observed: closest_monday(date)
12:
- name: Westland Anniversary Day
regions: [nz_wl]
mday: 1
observed: closest_monday(date)
- name: Christmas Day
regions: [nz]
mday: 25
observed: to_monday_if_weekend(date)
- name: Boxing Day
regions: [nz]
mday: 26
observed: to_weekday_if_boxing_weekend(date)
tests:
- given:
date: '2007-01-01'
regions: ["nz"]
options: ["informal"]
expect:
name: "New Year's Day"
- given:
date: '2007-01-02'
regions: ["nz"]
options: ["informal"]
expect:
name: "Day after New Year's Day"
- given:
date: '2007-02-06'
regions: ["nz"]
options: ["informal"]
expect:
name: "Waitangi Day"
- given:
date: '2007-04-06'
regions: ["nz"]
options: ["informal"]
expect:
name: "Good Friday"
- given:
date: '2007-04-09'
regions: ["nz"]
options: ["informal"]
expect:
name: "Easter Monday"
- given:
date: '2007-04-25'
regions: ["nz"]
options: ["informal"]
expect:
name: "ANZAC Day"
- given:
date: '2007-12-25'
regions: ["nz"]
options: ["informal"]
expect:
name: "Christmas Day"
- given:
date: '2007-12-26'
regions: ["nz"]
options: ["informal"]
expect:
name: "Boxing Day"
- given:
date: '2015-04-25'
regions: ["nz"]
expect:
name: "ANZAC Day"
- given:
date: '2015-04-27'
regions: ["nz"]
options: ["observed"]
expect:
name: "ANZAC Day"
- given:
date: '2016-04-25'
regions: ["nz"]
expect:
name: "ANZAC Day"
- given:
date: '2016-04-25'
regions: ["nz"]
options: ["observed"]
expect:
name: "ANZAC Day"
- given:
date: '2015-02-06'
regions: ["nz"]
expect:
name: "Waitangi Day"
- given:
date: '2015-02-06'
regions: ["nz"]
options: ["observed"]
expect:
name: "Waitangi Day"
- given:
date: '2016-02-06'
regions: ["nz"]
expect:
name: "Waitangi Day"
- given:
date: '2016-02-08'
regions: ["nz"]
options: ["observed"]
expect:
name: "Waitangi Day"
- given:
date: '2016-02-01'
regions: ["nz_ne"]
options: ["observed"]
expect:
name: "Nelson Anniversary Day"
- given:
date: '2017-01-30'
regions: ["nz_ne"]
options: ["observed"]
expect:
name: "Nelson Anniversary Day"
- given:
date: '2018-01-29'
regions: ["nz_ne"]
options: ["observed"]
expect:
name: "Nelson Anniversary Day"
- given:
date: '2019-02-04'
regions: ["nz_ne"]
options: ["observed"]
expect:
name: "Nelson Anniversary Day"
- given:
date: '2016-03-14'
regions: ["nz_ta"]
options: ["observed"]
expect:
name: "Taranaki Anniversary Day"
- given:
date: '2017-03-13'
regions: ["nz_ta"]
options: ["observed"]
expect:
name: "Taranaki Anniversary Day"
- given:
date: '2018-03-12'
regions: ["nz_ta"]
options: ["observed"]
expect:
name: "Taranaki Anniversary Day"
- given:
date: '2019-03-11'
regions: ["nz_ta"]
options: ["observed"]
expect:
name: "Taranaki Anniversary Day"
- given:
date: "2022-06-24"
regions: ["nz"]
expect:
name: "Matariki"
- given:
date: "2052-06-21"
regions: ["nz"]
expect:
name: "Matariki"
- given:
date: "2022-06-06"
regions: ["nz"]
expect:
name: "Queen's Birthday"
- given:
date: "2023-06-05"
regions: ["nz"]
expect:
name: "King's Birthday"
methods:
closest_monday:
arguments: date
ruby: |
if [1, 2, 3, 4].include?(date.wday)
date -= (date.wday - 1)
elsif 0 == date.wday
date += 1
else
date += 8 - date.wday
end
date
previous_friday:
arguments: date
ruby: |
date - 3
next_week:
arguments: date
ruby: |
date + 7
matariki:
# Matariki is based on the Māori lunar calendar (similar to Easter) so can't be
# easily calculated, so must be manually entered. Matariki falls on a Friday to
# give us long weekends.
arguments: year
ruby: |
@matariki_dates ||= {
'2022' => Date.civil(2022, 6, 24),
'2023' => Date.civil(2023, 7, 14),
'2024' => Date.civil(2024, 6, 28),
'2025' => Date.civil(2025, 6, 20),
'2026' => Date.civil(2026, 7, 10),
'2027' => Date.civil(2027, 6, 25),
'2028' => Date.civil(2028, 7, 14),
'2029' => Date.civil(2029, 7, 6),
'2030' => Date.civil(2030, 6, 21),
'2031' => Date.civil(2031, 7, 11),
'2032' => Date.civil(2032, 7, 2),
'2033' => Date.civil(2033, 6, 24),
'2034' => Date.civil(2034, 7, 7),
'2035' => Date.civil(2035, 6, 29),
'2036' => Date.civil(2036, 7, 18),
'2037' => Date.civil(2037, 7, 10),
'2038' => Date.civil(2038, 6, 25),
'2039' => Date.civil(2039, 7, 15),
'2040' => Date.civil(2040, 7, 6),
'2041' => Date.civil(2041, 7, 19),
'2042' => Date.civil(2042, 7, 11),
'2043' => Date.civil(2043, 7, 3),
'2044' => Date.civil(2044, 6, 24),
'2045' => Date.civil(2045, 7, 7),
'2046' => Date.civil(2046, 6, 29),
'2047' => Date.civil(2047, 7, 19),
'2048' => Date.civil(2048, 7, 3),
'2049' => Date.civil(2049, 6, 25),
'2050' => Date.civil(2050, 7, 15),
'2051' => Date.civil(2051, 6, 30),
'2052' => Date.civil(2052, 6, 21),
}
@matariki_dates[year.to_s]