nzholidays 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +26 -2
- data/lib/nzholidays.rb +3 -355
- data/lib/nzholidays/calendar.rb +324 -0
- data/lib/nzholidays/nztime.rb +35 -0
- data/lib/nzholidays/template.erb +10 -59
- data/lib/nzholidays/version.rb +1 -1
- data/nzholidays.gemspec +5 -5
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 235001adc9d6779a11e4ea2be66120298297f3dbe790d5e811a165f722c688da
|
4
|
+
data.tar.gz: 70d882ac257798df779a762db233397afc8935e567eac7dad9fa2a053ee6891a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9566f1fb48791abe92ef81f8b992336d271eb1df41d25817928496a659ff29c1d4f036cc8d93208b1fc2d3e4104e35df8235f242209062c209703ec87d338d3
|
7
|
+
data.tar.gz: f19dcb70eef764eee902502c801d8f89633c3813aae28fc0dd3540c5b70d1ca1412f3bf528386e7b38c005fb1639353cc8b6875d5657481a6db492edd6a1bde9
|
data/Rakefile
CHANGED
@@ -1,16 +1,40 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
|
+
require 'bundler/setup'
|
3
4
|
|
4
5
|
RSpec::Core::RakeTask.new(:spec)
|
5
6
|
|
7
|
+
SOURCE_URL = 'http://apps.employment.govt.nz/ical/public-holidays-all.ics'
|
8
|
+
FILE = 'public-holidays-all.ics'
|
9
|
+
|
6
10
|
task :default => [:generate, :spec]
|
7
11
|
|
8
|
-
task :
|
12
|
+
task :download do
|
13
|
+
require 'open-uri'
|
14
|
+
require 'net/http'
|
15
|
+
|
16
|
+
puts "Downloading #{SOURCE_URL}"
|
17
|
+
|
18
|
+
# Download the ICS file
|
19
|
+
open(FILE, 'wb') do |file|
|
20
|
+
file << open(SOURCE_URL).read
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
task :generate => [:download] do
|
9
25
|
|
10
26
|
require 'erb'
|
27
|
+
require 'icalendar'
|
28
|
+
require 'tzinfo'
|
29
|
+
require 'nzholidays/nztime'
|
30
|
+
|
31
|
+
cal_file = File.open(FILE)
|
32
|
+
calendars = Icalendar::Calendar.parse(cal_file)
|
11
33
|
|
12
34
|
template = 'lib/nzholidays/template.erb'
|
13
|
-
output = 'lib/nzholidays.rb'
|
35
|
+
output = 'lib/nzholidays/calendar.rb'
|
36
|
+
|
37
|
+
puts "Generating #{output}"
|
14
38
|
|
15
39
|
erb = ERB.new(File.read(template), nil, '-')
|
16
40
|
erb.filename = template
|
data/lib/nzholidays.rb
CHANGED
@@ -1,357 +1,5 @@
|
|
1
|
-
# Auto-generated at 2018-10-02 16:57:02 +1300
|
2
|
-
# Do not edit - see template lib/nzholidays/template.erb
|
3
|
-
# To regenerate, `bundle exec rake generate`
|
4
|
-
|
5
|
-
require "nzholidays/version"
|
6
1
|
require 'time'
|
7
2
|
require 'tzinfo'
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
NZ_TIME_ZONE = TZInfo::Timezone.get('Pacific/Auckland')
|
12
|
-
|
13
|
-
def self.nz_time(year, month, day)
|
14
|
-
|
15
|
-
# Holiday starts at the beginning of the given day
|
16
|
-
time = ::Time.new(year, month, day, 0, 0, 0)
|
17
|
-
|
18
|
-
# Find the UTC total offset (daylight savings or standard time) for time
|
19
|
-
|
20
|
-
# note period_for_local ignores timezone info in the time object
|
21
|
-
# http://www.rubydoc.info/gems/tzinfo/TZInfo/Timezone#period_for_local-instance_method
|
22
|
-
|
23
|
-
utc_total_offset = NZ_TIME_ZONE.period_for_local(time).utc_total_offset
|
24
|
-
|
25
|
-
time.getlocal(utc_total_offset)
|
26
|
-
end
|
27
|
-
|
28
|
-
HOLIDAYS = [
|
29
|
-
nz_time( 2009, 4, 10 ), # Good Friday
|
30
|
-
nz_time( 2009, 4, 13 ), # Easter Monday
|
31
|
-
nz_time( 2009, 2, 6 ), # Waitangi Day
|
32
|
-
nz_time( 2009, 4, 25 ), # ANZAC Day
|
33
|
-
nz_time( 2009, 6, 1 ), # Queen's Birthday
|
34
|
-
nz_time( 2009, 10, 26 ), # Labour Day
|
35
|
-
nz_time( 2009, 12, 26 ), # Boxing Day (Public Holiday for employees who would normally work on Saturday)
|
36
|
-
nz_time( 2009, 12, 25 ), # Christmas Day
|
37
|
-
nz_time( 2009, 1, 2 ), # Day after New Year's Day
|
38
|
-
nz_time( 2009, 12, 28 ), # Boxing Day Public Holiday for employees who would not normally work on Saturday
|
39
|
-
nz_time( 2010, 1, 1 ), # New Year's Day
|
40
|
-
nz_time( 2010, 4, 5 ), # Easter Monday
|
41
|
-
nz_time( 2010, 6, 7 ), # Queen's Birthday
|
42
|
-
nz_time( 2008, 12, 26 ), # Boxing Day
|
43
|
-
nz_time( 2008, 12, 25 ), # Christmas Day
|
44
|
-
nz_time( 2009, 1, 1 ), # New Year's Day
|
45
|
-
nz_time( 2010, 12, 25 ), # Christmas Day (Public Holiday for employees who would normally work on Saturday)
|
46
|
-
nz_time( 2010, 12, 28 ), # Boxing Day Public Holiday for employees who would not normally work on Sunday
|
47
|
-
nz_time( 2010, 12, 26 ), # Boxing Day (Public Holiday for employees who would normally work on Sunday)
|
48
|
-
nz_time( 2011, 1, 3 ), # New Year's Day Public Holiday for employees who would not normally work on Saturday
|
49
|
-
nz_time( 2011, 4, 22 ), # Good Friday
|
50
|
-
nz_time( 2011, 1, 4 ), # Day after New Year's Day Public Holiday for employees who would not normally work on Sunday
|
51
|
-
nz_time( 2011, 10, 24 ), # Labour Day
|
52
|
-
nz_time( 2011, 4, 25 ), # Easter Monday
|
53
|
-
nz_time( 2011, 6, 6 ), # Queen's Birthday
|
54
|
-
nz_time( 2011, 12, 25 ), # Christmas Day (Public Holiday for employees who would normally work on Sunday)
|
55
|
-
nz_time( 2011, 12, 27 ), # Christmas Day (Public Holiday for employees who would not normally work on Sunday)
|
56
|
-
nz_time( 2011, 12, 26 ), # Boxing Day
|
57
|
-
nz_time( 2012, 1, 3 ), # New Year's Day Public Holiday for employees who would not normally work on Sunday
|
58
|
-
nz_time( 2010, 4, 2 ), # Good Friday
|
59
|
-
nz_time( 2010, 10, 25 ), # Labour Day
|
60
|
-
nz_time( 2010, 12, 27 ), # Christmas Day Public Holiday for employees who would not normally work on Saturday
|
61
|
-
nz_time( 2012, 4, 9 ), # Easter Monday
|
62
|
-
nz_time( 2012, 10, 22 ), # Labour Day
|
63
|
-
nz_time( 2012, 6, 4 ), # Queen's Birthday
|
64
|
-
nz_time( 2012, 12, 26 ), # Boxing Day
|
65
|
-
nz_time( 2012, 12, 25 ), # Christmas Day
|
66
|
-
nz_time( 2013, 1, 1 ), # New Year's Day
|
67
|
-
nz_time( 2013, 1, 2 ), # Day after New Year's Day
|
68
|
-
nz_time( 2013, 4, 1 ), # Easter Monday
|
69
|
-
nz_time( 2013, 3, 29 ), # Good Friday
|
70
|
-
nz_time( 2013, 10, 28 ), # Labour Day
|
71
|
-
nz_time( 2013, 6, 3 ), # Queen's Birthday
|
72
|
-
nz_time( 2013, 12, 25 ), # Christmas Day
|
73
|
-
nz_time( 2013, 12, 26 ), # Boxing Day
|
74
|
-
nz_time( 2012, 1, 1 ), # New Year's Day (Public Holiday for employees who would normally work on Sunday)
|
75
|
-
nz_time( 2012, 4, 6 ), # Good Friday
|
76
|
-
nz_time( 2012, 1, 2 ), # Day after New Year's Day
|
77
|
-
nz_time( 2014, 4, 18 ), # Good Friday
|
78
|
-
nz_time( 2014, 1, 2 ), # Day after New Year's Day
|
79
|
-
nz_time( 2014, 1, 1 ), # New Year's Day
|
80
|
-
nz_time( 2014, 4, 21 ), # Easter Monday
|
81
|
-
nz_time( 2010, 1, 4 ), # Day after New Year's Day Public Holiday for employees who would not normally work on Saturday
|
82
|
-
nz_time( 2010, 4, 25 ), # ANZAC Day
|
83
|
-
nz_time( 2010, 2, 6 ), # Waitangi Day
|
84
|
-
nz_time( 2011, 4, 25 ), # ANZAC Day
|
85
|
-
nz_time( 2011, 2, 6 ), # Waitangi Day
|
86
|
-
nz_time( 2014, 4, 25 ), # ANZAC Day
|
87
|
-
nz_time( 2013, 4, 25 ), # ANZAC Day
|
88
|
-
nz_time( 2014, 2, 6 ), # Waitangi Day
|
89
|
-
nz_time( 2010, 1, 2 ), # Day after New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
90
|
-
nz_time( 2011, 1, 1 ), # New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
91
|
-
nz_time( 2011, 1, 2 ), # Day after New Year's Day (Public Holiday for employees who would normally work on Sunday)
|
92
|
-
nz_time( 2012, 4, 25 ), # ANZAC Day
|
93
|
-
nz_time( 2012, 2, 6 ), # Waitangi Day
|
94
|
-
nz_time( 2013, 2, 6 ), # Waitangi Day
|
95
|
-
nz_time( 2014, 10, 27 ), # Labour Day
|
96
|
-
nz_time( 2014, 12, 25 ), # Christmas Day
|
97
|
-
nz_time( 2014, 6, 2 ), # Queen's Birthday
|
98
|
-
nz_time( 2015, 1, 1 ), # New Year's Day
|
99
|
-
nz_time( 2015, 4, 3 ), # Good Friday
|
100
|
-
nz_time( 2014, 12, 26 ), # Boxing Day
|
101
|
-
nz_time( 2015, 1, 2 ), # Day after New Year's Day
|
102
|
-
nz_time( 2015, 4, 6 ), # Easter Monday
|
103
|
-
nz_time( 2015, 12, 25 ), # Christmas Day
|
104
|
-
nz_time( 2015, 6, 1 ), # Queen's Birthday
|
105
|
-
nz_time( 2015, 10, 26 ), # Labour Day
|
106
|
-
nz_time( 2015, 12, 28 ), # Boxing Day (Public Holiday for employees who would not normally work on Saturday)
|
107
|
-
nz_time( 2016, 3, 25 ), # Good Friday
|
108
|
-
nz_time( 2016, 1, 1 ), # New Year's Day
|
109
|
-
nz_time( 2016, 1, 4 ), # Day after New Year's Day (Public Holiday for employees who would not normally work on Saturday)
|
110
|
-
nz_time( 2016, 3, 28 ), # Easter Monday
|
111
|
-
nz_time( 2016, 12, 25 ), # Christmas Day (Public Holiday for employees who would normally work on Sunday)
|
112
|
-
nz_time( 2016, 6, 6 ), # Queen's Birthday
|
113
|
-
nz_time( 2016, 10, 24 ), # Labour Day
|
114
|
-
nz_time( 2016, 12, 26 ), # Boxing Day
|
115
|
-
nz_time( 2016, 12, 27 ), # Christmas Day (Public Holiday for employees who would not normally work on Sunday)
|
116
|
-
nz_time( 2015, 2, 6 ), # Waitangi Day
|
117
|
-
nz_time( 2015, 4, 25 ), # ANZAC Day
|
118
|
-
nz_time( 2016, 2, 6 ), # Waitangi Day
|
119
|
-
nz_time( 2016, 4, 25 ), # ANZAC Day
|
120
|
-
nz_time( 2016, 1, 2 ), # Day after New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
121
|
-
nz_time( 2015, 12, 26 ), # Boxing Day (Public Holiday for employees who would normally work on Saturday)
|
122
|
-
nz_time( 2015, 4, 27 ), # ANZAC Day (Mondayised)
|
123
|
-
nz_time( 2016, 2, 8 ), # Waitangi Day (Mondayised)
|
124
|
-
nz_time( 2017, 1, 1 ), # New Year's Day (Public Holiday for employees who would normally work on Sunday)
|
125
|
-
nz_time( 2017, 1, 2 ), # Day after New Year's Day
|
126
|
-
nz_time( 2017, 1, 3 ), # New Year's Day (Public Holiday for employees who would not normally work on Sunday)
|
127
|
-
nz_time( 2017, 2, 6 ), # Waitangi Day
|
128
|
-
nz_time( 2017, 4, 14 ), # Good Friday
|
129
|
-
nz_time( 2017, 4, 17 ), # Easter Monday
|
130
|
-
nz_time( 2017, 6, 5 ), # Queen's Birthday
|
131
|
-
nz_time( 2017, 4, 25 ), # ANZAC Day
|
132
|
-
nz_time( 2017, 10, 23 ), # Labour Day
|
133
|
-
nz_time( 2017, 12, 25 ), # Christmas Day
|
134
|
-
nz_time( 2017, 12, 26 ), # Boxing Day
|
135
|
-
nz_time( 2021, 12, 28 ), # Boxing Day (Public Holiday for employees who would not normally work on Sunday)
|
136
|
-
nz_time( 2021, 12, 26 ), # Boxing Day (Public Holiday for employees who would normally work on Sunday)
|
137
|
-
nz_time( 2021, 12, 27 ), # Christmas Day (Public Holiday for employees who would not normally work on Saturday)
|
138
|
-
nz_time( 2021, 12, 25 ), # Christmas Day (Public Holiday for employees who would normally work on Saturday)
|
139
|
-
nz_time( 2021, 10, 25 ), # Labour Day
|
140
|
-
nz_time( 2021, 6, 7 ), # Queen's Birthday
|
141
|
-
nz_time( 2021, 4, 26 ), # ANZAC Day (Mondayised)
|
142
|
-
nz_time( 2021, 4, 25 ), # ANZAC Day
|
143
|
-
nz_time( 2021, 4, 5 ), # Easter Monday
|
144
|
-
nz_time( 2021, 4, 2 ), # Good Friday
|
145
|
-
nz_time( 2021, 2, 8 ), # Waitangi Day (Mondayised)
|
146
|
-
nz_time( 2021, 2, 6 ), # Waitangi Day
|
147
|
-
nz_time( 2021, 1, 4 ), # Day after New Year's Day (Public Holiday for employees who would not normally work on Saturday)
|
148
|
-
nz_time( 2021, 1, 2 ), # Day after New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
149
|
-
nz_time( 2021, 1, 1 ), # New Year's Day
|
150
|
-
nz_time( 2020, 12, 28 ), # Boxing Day (Public Holiday for employees who would not normally work on Saturday)
|
151
|
-
nz_time( 2020, 12, 26 ), # Boxing Day (Public Holiday for employees who would normally work on Saturday)
|
152
|
-
nz_time( 2020, 12, 25 ), # Christmas Day
|
153
|
-
nz_time( 2020, 10, 26 ), # Labour Day
|
154
|
-
nz_time( 2020, 6, 1 ), # Queen's Birthday
|
155
|
-
nz_time( 2020, 4, 27 ), # ANZAC Day (Mondayised)
|
156
|
-
nz_time( 2020, 4, 25 ), # ANZAC Day
|
157
|
-
nz_time( 2020, 4, 13 ), # Easter Monday
|
158
|
-
nz_time( 2020, 4, 10 ), # Good Friday
|
159
|
-
nz_time( 2020, 2, 6 ), # Waitangi Day
|
160
|
-
nz_time( 2020, 1, 2 ), # Day after New Year's Day
|
161
|
-
nz_time( 2020, 1, 1 ), # New Year's Day
|
162
|
-
nz_time( 2019, 12, 26 ), # Boxing Day
|
163
|
-
nz_time( 2019, 12, 25 ), # Christmas Day
|
164
|
-
nz_time( 2019, 10, 28 ), # Labour Day
|
165
|
-
nz_time( 2019, 6, 3 ), # Queen's Birthday
|
166
|
-
nz_time( 2019, 4, 25 ), # ANZAC Day
|
167
|
-
nz_time( 2019, 4, 22 ), # Easter Monday
|
168
|
-
nz_time( 2019, 4, 19 ), # Good Friday
|
169
|
-
nz_time( 2019, 2, 6 ), # Waitangi Day
|
170
|
-
nz_time( 2019, 1, 2 ), # Day after New Year's Day
|
171
|
-
nz_time( 2019, 1, 1 ), # New Year's Day
|
172
|
-
nz_time( 2018, 12, 26 ), # Boxing Day
|
173
|
-
nz_time( 2018, 12, 25 ), # Christmas Day
|
174
|
-
nz_time( 2018, 10, 22 ), # Labour Day
|
175
|
-
nz_time( 2018, 6, 4 ), # Queen's Birthday
|
176
|
-
nz_time( 2018, 4, 25 ), # ANZAC Day
|
177
|
-
nz_time( 2018, 4, 2 ), # Easter Monday
|
178
|
-
nz_time( 2018, 3, 30 ), # Good Friday
|
179
|
-
nz_time( 2018, 2, 6 ), # Waitangi Day
|
180
|
-
nz_time( 2018, 1, 2 ), # Day after New Year's Day
|
181
|
-
nz_time( 2018, 1, 1 ), # New Year's Day
|
182
|
-
]
|
183
|
-
|
184
|
-
ANNIVERSARIES = [
|
185
|
-
nz_time( 2008, 12, 1 ), # Westland Anniversary Day
|
186
|
-
nz_time( 2008, 12, 1 ), # Chatham Islands Anniversary Day
|
187
|
-
nz_time( 2009, 1, 26 ), # Auckland Anniversary Day
|
188
|
-
nz_time( 2009, 1, 19 ), # Wellington Anniversary Day
|
189
|
-
nz_time( 2009, 2, 2 ), # Nelson Anniversary Day
|
190
|
-
nz_time( 2009, 1, 19 ), # Southland Anniversary Day
|
191
|
-
nz_time( 2009, 3, 9 ), # Taranaki Anniversary Day
|
192
|
-
nz_time( 2009, 9, 28 ), # South Canterbury Anniversary Day
|
193
|
-
nz_time( 2009, 11, 13 ), # Canterbury Anniversary Day
|
194
|
-
nz_time( 2009, 11, 30 ), # Chatham Islands Anniversary Day
|
195
|
-
nz_time( 2010, 1, 25 ), # Wellington Anniversary Day
|
196
|
-
nz_time( 2009, 11, 30 ), # Westland Anniversary Day
|
197
|
-
nz_time( 2010, 2, 1 ), # Auckland Anniversary Day
|
198
|
-
nz_time( 2010, 3, 8 ), # Taranaki Anniversary Day
|
199
|
-
nz_time( 2010, 1, 18 ), # Southland Anniversary Day
|
200
|
-
nz_time( 2010, 2, 1 ), # Nelson Anniversary Day
|
201
|
-
nz_time( 2010, 9, 27 ), # South Canterbury Anniversary Day
|
202
|
-
nz_time( 2010, 3, 22 ), # Otago Anniversary Day
|
203
|
-
nz_time( 2010, 11, 1 ), # Marlborough Anniversary Day
|
204
|
-
nz_time( 2010, 10, 22 ), # Hawkes' Bay Anniversary Day
|
205
|
-
nz_time( 2009, 3, 23 ), # Otago Anniversary Day
|
206
|
-
nz_time( 2009, 11, 2 ), # Marlborough Anniversary Day
|
207
|
-
nz_time( 2009, 10, 23 ), # Hawkes' Bay Anniversary Day
|
208
|
-
nz_time( 2010, 11, 29 ), # Chatham Islands Anniversary Day
|
209
|
-
nz_time( 2011, 1, 31 ), # Nelson Anniversary Day
|
210
|
-
nz_time( 2011, 1, 17 ), # Southland Anniversary Day
|
211
|
-
nz_time( 2011, 1, 24 ), # Wellington Anniversary Day
|
212
|
-
nz_time( 2011, 3, 14 ), # Taranaki Anniversary Day
|
213
|
-
nz_time( 2011, 9, 26 ), # South Canterbury Anniversary Day
|
214
|
-
nz_time( 2011, 3, 21 ), # Otago Anniversary Day
|
215
|
-
nz_time( 2011, 10, 21 ), # Hawkes' Bay Anniversary Day
|
216
|
-
nz_time( 2011, 11, 11 ), # Canterbury Anniversary Day
|
217
|
-
nz_time( 2011, 10, 31 ), # Marlborough Anniversary Day
|
218
|
-
nz_time( 2011, 12, 5 ), # Westland Anniversary Day
|
219
|
-
nz_time( 2011, 11, 28 ), # Chatham Islands Anniversary Day
|
220
|
-
nz_time( 2012, 1, 30 ), # Auckland Anniversary Day
|
221
|
-
nz_time( 2010, 11, 29 ), # Westland Anniversary Day
|
222
|
-
nz_time( 2011, 1, 31 ), # Auckland Anniversary Day
|
223
|
-
nz_time( 2010, 11, 12 ), # Canterbury Anniversary Day
|
224
|
-
nz_time( 2012, 3, 12 ), # Taranaki Anniversary Day
|
225
|
-
nz_time( 2012, 3, 26 ), # Otago Anniversary Day
|
226
|
-
nz_time( 2012, 9, 24 ), # South Canterbury Anniversary Day
|
227
|
-
nz_time( 2012, 10, 19 ), # Hawkes' Bay Anniversary Day
|
228
|
-
nz_time( 2012, 11, 16 ), # Canterbury Anniversary Day
|
229
|
-
nz_time( 2012, 10, 29 ), # Marlborough Anniversary Day
|
230
|
-
nz_time( 2013, 1, 28 ), # Auckland Anniversary Day
|
231
|
-
nz_time( 2012, 12, 3 ), # Westland Anniversary Day
|
232
|
-
nz_time( 2012, 12, 3 ), # Chatham Islands Anniversary Day
|
233
|
-
nz_time( 2013, 1, 21 ), # Wellington Anniversary Day
|
234
|
-
nz_time( 2013, 1, 21 ), # Southland Anniversary Day
|
235
|
-
nz_time( 2013, 2, 4 ), # Nelson Anniversary Day
|
236
|
-
nz_time( 2013, 3, 25 ), # Otago Anniversary Day
|
237
|
-
nz_time( 2012, 1, 23 ), # Wellington Anniversary Day
|
238
|
-
nz_time( 2012, 1, 16 ), # Southland Anniversary Day
|
239
|
-
nz_time( 2012, 1, 30 ), # Nelson Anniversary Day
|
240
|
-
nz_time( 2013, 11, 4 ), # Marlborough Anniversary Day
|
241
|
-
nz_time( 2013, 11, 15 ), # Canterbury Anniversary Day
|
242
|
-
nz_time( 2014, 1, 27 ), # Auckland Anniversary Day
|
243
|
-
nz_time( 2013, 12, 2 ), # Westland Anniversary Day
|
244
|
-
nz_time( 2013, 12, 2 ), # Chatham Islands Anniversary Day
|
245
|
-
nz_time( 2014, 1, 20 ), # Wellington Anniversary Day
|
246
|
-
nz_time( 2014, 4, 22 ), # Southland Anniversary Day
|
247
|
-
nz_time( 2014, 2, 3 ), # Nelson Anniversary Day
|
248
|
-
nz_time( 2014, 3, 10 ), # Taranaki Anniversary Day
|
249
|
-
nz_time( 2014, 3, 24 ), # Otago Anniversary Day
|
250
|
-
nz_time( 2013, 3, 11 ), # Taranaki Anniversary Day
|
251
|
-
nz_time( 2013, 9, 23 ), # South Canterbury Anniversary Day
|
252
|
-
nz_time( 2013, 10, 25 ), # Hawkes' Bay Anniversary Day
|
253
|
-
nz_time( 2014, 10, 24 ), # Hawkes' Bay Anniversary Day
|
254
|
-
nz_time( 2014, 11, 14 ), # Canterbury Anniversary Day
|
255
|
-
nz_time( 2014, 9, 22 ), # South Canterbury Anniversary Day
|
256
|
-
nz_time( 2014, 11, 3 ), # Marlborough Anniversary Day
|
257
|
-
nz_time( 2014, 12, 1 ), # Westland Anniversary Day
|
258
|
-
nz_time( 2014, 12, 1 ), # Chatham Islands Anniversary Day
|
259
|
-
nz_time( 2015, 1, 19 ), # Wellington Anniversary Day
|
260
|
-
nz_time( 2015, 4, 7 ), # Southland Anniversary Day
|
261
|
-
nz_time( 2015, 1, 26 ), # Auckland Anniversary Day
|
262
|
-
nz_time( 2015, 3, 23 ), # Otago Anniversary Day
|
263
|
-
nz_time( 2015, 2, 2 ), # Nelson Anniversary Day
|
264
|
-
nz_time( 2015, 3, 9 ), # Taranaki Anniversary Day
|
265
|
-
nz_time( 2015, 10, 23 ), # Hawkes' Bay Anniversary Day
|
266
|
-
nz_time( 2015, 9, 28 ), # South Canterbury Anniversary Day
|
267
|
-
nz_time( 2015, 11, 2 ), # Marlborough Anniversary Day
|
268
|
-
nz_time( 2015, 11, 30 ), # Westland Anniversary Day
|
269
|
-
nz_time( 2015, 11, 13 ), # Canterbury Anniversary Day
|
270
|
-
nz_time( 2016, 1, 25 ), # Wellington Anniversary Day
|
271
|
-
nz_time( 2016, 3, 29 ), # Southland Anniversary Day
|
272
|
-
nz_time( 2015, 11, 30 ), # Chatham Islands Anniversary Day
|
273
|
-
nz_time( 2016, 2, 1 ), # Nelson Anniversary Day
|
274
|
-
nz_time( 2016, 2, 1 ), # Auckland Anniversary Day
|
275
|
-
nz_time( 2016, 3, 21 ), # Otago Anniversary Day
|
276
|
-
nz_time( 2016, 3, 14 ), # Taranaki Anniversary Day
|
277
|
-
nz_time( 2016, 9, 26 ), # South Canterbury Anniversary Day
|
278
|
-
nz_time( 2016, 10, 21 ), # Hawkes' Bay Anniversary Day
|
279
|
-
nz_time( 2016, 10, 31 ), # Marlborough Anniversary Day
|
280
|
-
nz_time( 2016, 11, 11 ), # Canterbury Anniversary Day
|
281
|
-
nz_time( 2016, 11, 28 ), # Westland Anniversary Day
|
282
|
-
nz_time( 2016, 11, 28 ), # Chatham Islands Anniversary Day
|
283
|
-
nz_time( 2017, 1, 23 ), # Wellington Anniversary
|
284
|
-
nz_time( 2017, 1, 30 ), # Auckland Anniversary
|
285
|
-
nz_time( 2017, 1, 30 ), # Nelson Anniversary
|
286
|
-
nz_time( 2017, 3, 13 ), # Taranaki Anniversary
|
287
|
-
nz_time( 2017, 3, 20 ), # Otago Anniversary
|
288
|
-
nz_time( 2017, 4, 18 ), # Southland Anniversary
|
289
|
-
nz_time( 2017, 9, 25 ), # Canterbury (South) Anniversary
|
290
|
-
nz_time( 2017, 10, 20 ), # Hawke's Bay Anniversary
|
291
|
-
nz_time( 2017, 10, 30 ), # Marlborough Anniversary
|
292
|
-
nz_time( 2017, 11, 27 ), # Chatham Islands Anniversary
|
293
|
-
nz_time( 2017, 11, 17 ), # Canterbury Anniversary
|
294
|
-
nz_time( 2017, 12, 4 ), # Westland Anniversary
|
295
|
-
nz_time( 2021, 11, 29 ), # Chatham Islands Anniversary
|
296
|
-
nz_time( 2021, 11, 29 ), # Westland Anniversary
|
297
|
-
nz_time( 2021, 11, 12 ), # Canterbury Anniversary
|
298
|
-
nz_time( 2021, 11, 1 ), # Marlborough Anniversary
|
299
|
-
nz_time( 2021, 10, 22 ), # Hawke's Bay Anniversary
|
300
|
-
nz_time( 2021, 9, 27 ), # Canterbury (South) Anniversary
|
301
|
-
nz_time( 2021, 4, 6 ), # Southland Anniversary
|
302
|
-
nz_time( 2021, 3, 22 ), # Otago Anniversary
|
303
|
-
nz_time( 2021, 3, 8 ), # Taranaki Anniversary
|
304
|
-
nz_time( 2021, 2, 1 ), # Nelson Anniversary
|
305
|
-
nz_time( 2021, 2, 1 ), # Auckland Anniversary
|
306
|
-
nz_time( 2021, 1, 25 ), # Wellington Anniversary
|
307
|
-
nz_time( 2020, 11, 30 ), # Chatham Islands Anniversary
|
308
|
-
nz_time( 2020, 11, 30 ), # Westland Anniversary
|
309
|
-
nz_time( 2020, 11, 13 ), # Canterbury Anniversary
|
310
|
-
nz_time( 2020, 11, 2 ), # Marlborough Anniversary
|
311
|
-
nz_time( 2020, 10, 23 ), # Hawke's Bay Anniversary
|
312
|
-
nz_time( 2020, 9, 28 ), # Canterbury (South) Anniversary
|
313
|
-
nz_time( 2020, 4, 14 ), # Southland Anniversary
|
314
|
-
nz_time( 2020, 3, 23 ), # Otago Anniversary
|
315
|
-
nz_time( 2020, 3, 9 ), # Taranaki Anniversary
|
316
|
-
nz_time( 2020, 2, 3 ), # Nelson Anniversary
|
317
|
-
nz_time( 2020, 1, 27 ), # Auckland Anniversary
|
318
|
-
nz_time( 2020, 1, 20 ), # Wellington Anniversary
|
319
|
-
nz_time( 2019, 12, 2 ), # Chatham Islands Anniversary
|
320
|
-
nz_time( 2019, 12, 2 ), # Westland Anniversary
|
321
|
-
nz_time( 2019, 11, 15 ), # Canterbury Anniversary
|
322
|
-
nz_time( 2019, 11, 4 ), # Marlborough Anniversary
|
323
|
-
nz_time( 2019, 10, 25 ), # Hawke's Bay Anniversary
|
324
|
-
nz_time( 2019, 9, 23 ), # Canterbury (South) Anniversary
|
325
|
-
nz_time( 2019, 4, 23 ), # Southland Anniversary
|
326
|
-
nz_time( 2019, 3, 25 ), # Otago Anniversary
|
327
|
-
nz_time( 2019, 3, 11 ), # Taranaki Anniversary
|
328
|
-
nz_time( 2019, 2, 4 ), # Nelson Anniversary
|
329
|
-
nz_time( 2019, 1, 28 ), # Auckland Anniversary
|
330
|
-
nz_time( 2019, 1, 21 ), # Wellington Anniversary
|
331
|
-
nz_time( 2018, 12, 3 ), # Chatham Islands Anniversary
|
332
|
-
nz_time( 2018, 12, 3 ), # Westland Anniversary
|
333
|
-
nz_time( 2018, 11, 16 ), # Canterbury Anniversary
|
334
|
-
nz_time( 2018, 10, 29 ), # Marlborough Anniversary
|
335
|
-
nz_time( 2018, 10, 19 ), # Hawke's Bay Anniversary
|
336
|
-
nz_time( 2018, 9, 24 ), # Canterbury (South) Anniversary
|
337
|
-
nz_time( 2018, 4, 3 ), # Southland Anniversary
|
338
|
-
nz_time( 2018, 3, 26 ), # Otago Anniversary
|
339
|
-
nz_time( 2018, 3, 12 ), # Taranaki Anniversary
|
340
|
-
nz_time( 2018, 1, 29 ), # Nelson Anniversary
|
341
|
-
nz_time( 2018, 1, 29 ), # Auckland Anniversary
|
342
|
-
nz_time( 2018, 1, 22 ), # Wellington Anniversary
|
343
|
-
]
|
344
|
-
|
345
|
-
def self.nz_public_holiday?(query)
|
346
|
-
!!HOLIDAYS.find do |hol|
|
347
|
-
hol.year == query.year && hol.month == query.month && hol.day == query.day
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
def self.nz_anniversary?(query)
|
352
|
-
!!ANNIVERSARIES.find do |hol|
|
353
|
-
hol.year == query.year && hol.month == query.month && hol.day == query.day
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
end
|
3
|
+
require 'nzholidays/version'
|
4
|
+
require 'nzholidays/nztime'
|
5
|
+
require 'nzholidays/calendar'
|
@@ -0,0 +1,324 @@
|
|
1
|
+
# Auto-generated at 2018-10-03 15:10:33 +1300
|
2
|
+
# Do not edit - see template lib/nzholidays/template.erb
|
3
|
+
# To regenerate, `bundle exec rake generate`
|
4
|
+
|
5
|
+
module Nzholidays
|
6
|
+
|
7
|
+
HOLIDAYS = [
|
8
|
+
Time.new(2008, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
9
|
+
Time.new(2008, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
10
|
+
Time.new(2009, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
11
|
+
Time.new(2009, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
12
|
+
Time.new(2009, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
13
|
+
Time.new(2009, 4, 10, 0, 0, 0, 43200), # Good Friday
|
14
|
+
Time.new(2009, 4, 13, 0, 0, 0, 43200), # Easter Monday
|
15
|
+
Time.new(2009, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
16
|
+
Time.new(2009, 6, 1, 0, 0, 0, 43200), # Queen's Birthday
|
17
|
+
Time.new(2009, 10, 26, 0, 0, 0, 46800), # Labour Day
|
18
|
+
Time.new(2009, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
19
|
+
Time.new(2009, 12, 26, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would normally work on Saturday)
|
20
|
+
Time.new(2009, 12, 28, 0, 0, 0, 46800), # Boxing Day Public Holiday for employees who would not normally work on Saturday
|
21
|
+
Time.new(2010, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
22
|
+
Time.new(2010, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
23
|
+
Time.new(2010, 1, 4, 0, 0, 0, 46800), # Day after New Year's Day Public Holiday for employees who would not normally work on Saturday
|
24
|
+
Time.new(2010, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
25
|
+
Time.new(2010, 4, 2, 0, 0, 0, 46800), # Good Friday
|
26
|
+
Time.new(2010, 4, 5, 0, 0, 0, 43200), # Easter Monday
|
27
|
+
Time.new(2010, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
28
|
+
Time.new(2010, 6, 7, 0, 0, 0, 43200), # Queen's Birthday
|
29
|
+
Time.new(2010, 10, 25, 0, 0, 0, 46800), # Labour Day
|
30
|
+
Time.new(2010, 12, 25, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would normally work on Saturday)
|
31
|
+
Time.new(2010, 12, 26, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would normally work on Sunday)
|
32
|
+
Time.new(2010, 12, 27, 0, 0, 0, 46800), # Christmas Day Public Holiday for employees who would not normally work on Saturday
|
33
|
+
Time.new(2010, 12, 28, 0, 0, 0, 46800), # Boxing Day Public Holiday for employees who would not normally work on Sunday
|
34
|
+
Time.new(2011, 1, 1, 0, 0, 0, 46800), # New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
35
|
+
Time.new(2011, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day (Public Holiday for employees who would normally work on Sunday)
|
36
|
+
Time.new(2011, 1, 3, 0, 0, 0, 46800), # New Year's Day Public Holiday for employees who would not normally work on Saturday
|
37
|
+
Time.new(2011, 1, 4, 0, 0, 0, 46800), # Day after New Year's Day Public Holiday for employees who would not normally work on Sunday
|
38
|
+
Time.new(2011, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
39
|
+
Time.new(2011, 4, 22, 0, 0, 0, 43200), # Good Friday
|
40
|
+
Time.new(2011, 4, 25, 0, 0, 0, 43200), # Easter Monday
|
41
|
+
Time.new(2011, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
42
|
+
Time.new(2011, 6, 6, 0, 0, 0, 43200), # Queen's Birthday
|
43
|
+
Time.new(2011, 10, 24, 0, 0, 0, 46800), # Labour Day
|
44
|
+
Time.new(2011, 12, 25, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would normally work on Sunday)
|
45
|
+
Time.new(2011, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
46
|
+
Time.new(2011, 12, 27, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would not normally work on Sunday)
|
47
|
+
Time.new(2012, 1, 1, 0, 0, 0, 46800), # New Year's Day (Public Holiday for employees who would normally work on Sunday)
|
48
|
+
Time.new(2012, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
49
|
+
Time.new(2012, 1, 3, 0, 0, 0, 46800), # New Year's Day Public Holiday for employees who would not normally work on Sunday
|
50
|
+
Time.new(2012, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
51
|
+
Time.new(2012, 4, 6, 0, 0, 0, 43200), # Good Friday
|
52
|
+
Time.new(2012, 4, 9, 0, 0, 0, 43200), # Easter Monday
|
53
|
+
Time.new(2012, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
54
|
+
Time.new(2012, 6, 4, 0, 0, 0, 43200), # Queen's Birthday
|
55
|
+
Time.new(2012, 10, 22, 0, 0, 0, 46800), # Labour Day
|
56
|
+
Time.new(2012, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
57
|
+
Time.new(2012, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
58
|
+
Time.new(2013, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
59
|
+
Time.new(2013, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
60
|
+
Time.new(2013, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
61
|
+
Time.new(2013, 3, 29, 0, 0, 0, 46800), # Good Friday
|
62
|
+
Time.new(2013, 4, 1, 0, 0, 0, 46800), # Easter Monday
|
63
|
+
Time.new(2013, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
64
|
+
Time.new(2013, 6, 3, 0, 0, 0, 43200), # Queen's Birthday
|
65
|
+
Time.new(2013, 10, 28, 0, 0, 0, 46800), # Labour Day
|
66
|
+
Time.new(2013, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
67
|
+
Time.new(2013, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
68
|
+
Time.new(2014, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
69
|
+
Time.new(2014, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
70
|
+
Time.new(2014, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
71
|
+
Time.new(2014, 4, 18, 0, 0, 0, 43200), # Good Friday
|
72
|
+
Time.new(2014, 4, 21, 0, 0, 0, 43200), # Easter Monday
|
73
|
+
Time.new(2014, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
74
|
+
Time.new(2014, 6, 2, 0, 0, 0, 43200), # Queen's Birthday
|
75
|
+
Time.new(2014, 10, 27, 0, 0, 0, 46800), # Labour Day
|
76
|
+
Time.new(2014, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
77
|
+
Time.new(2014, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
78
|
+
Time.new(2015, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
79
|
+
Time.new(2015, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
80
|
+
Time.new(2015, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
81
|
+
Time.new(2015, 4, 3, 0, 0, 0, 46800), # Good Friday
|
82
|
+
Time.new(2015, 4, 6, 0, 0, 0, 43200), # Easter Monday
|
83
|
+
Time.new(2015, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
84
|
+
Time.new(2015, 4, 27, 0, 0, 0, 43200), # ANZAC Day (Mondayised)
|
85
|
+
Time.new(2015, 6, 1, 0, 0, 0, 43200), # Queen's Birthday
|
86
|
+
Time.new(2015, 10, 26, 0, 0, 0, 46800), # Labour Day
|
87
|
+
Time.new(2015, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
88
|
+
Time.new(2015, 12, 26, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would normally work on Saturday)
|
89
|
+
Time.new(2015, 12, 28, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would not normally work on Saturday)
|
90
|
+
Time.new(2016, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
91
|
+
Time.new(2016, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
92
|
+
Time.new(2016, 1, 4, 0, 0, 0, 46800), # Day after New Year's Day (Public Holiday for employees who would not normally work on Saturday)
|
93
|
+
Time.new(2016, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
94
|
+
Time.new(2016, 2, 8, 0, 0, 0, 46800), # Waitangi Day (Mondayised)
|
95
|
+
Time.new(2016, 3, 25, 0, 0, 0, 46800), # Good Friday
|
96
|
+
Time.new(2016, 3, 28, 0, 0, 0, 46800), # Easter Monday
|
97
|
+
Time.new(2016, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
98
|
+
Time.new(2016, 6, 6, 0, 0, 0, 43200), # Queen's Birthday
|
99
|
+
Time.new(2016, 10, 24, 0, 0, 0, 46800), # Labour Day
|
100
|
+
Time.new(2016, 12, 25, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would normally work on Sunday)
|
101
|
+
Time.new(2016, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
102
|
+
Time.new(2016, 12, 27, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would not normally work on Sunday)
|
103
|
+
Time.new(2017, 1, 1, 0, 0, 0, 46800), # New Year's Day (Public Holiday for employees who would normally work on Sunday)
|
104
|
+
Time.new(2017, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
105
|
+
Time.new(2017, 1, 3, 0, 0, 0, 46800), # New Year's Day (Public Holiday for employees who would not normally work on Sunday)
|
106
|
+
Time.new(2017, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
107
|
+
Time.new(2017, 4, 14, 0, 0, 0, 43200), # Good Friday
|
108
|
+
Time.new(2017, 4, 17, 0, 0, 0, 43200), # Easter Monday
|
109
|
+
Time.new(2017, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
110
|
+
Time.new(2017, 6, 5, 0, 0, 0, 43200), # Queen's Birthday
|
111
|
+
Time.new(2017, 10, 23, 0, 0, 0, 46800), # Labour Day
|
112
|
+
Time.new(2017, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
113
|
+
Time.new(2017, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
114
|
+
Time.new(2018, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
115
|
+
Time.new(2018, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
116
|
+
Time.new(2018, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
117
|
+
Time.new(2018, 3, 30, 0, 0, 0, 46800), # Good Friday
|
118
|
+
Time.new(2018, 4, 2, 0, 0, 0, 43200), # Easter Monday
|
119
|
+
Time.new(2018, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
120
|
+
Time.new(2018, 6, 4, 0, 0, 0, 43200), # Queen's Birthday
|
121
|
+
Time.new(2018, 10, 22, 0, 0, 0, 46800), # Labour Day
|
122
|
+
Time.new(2018, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
123
|
+
Time.new(2018, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
124
|
+
Time.new(2019, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
125
|
+
Time.new(2019, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
126
|
+
Time.new(2019, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
127
|
+
Time.new(2019, 4, 19, 0, 0, 0, 43200), # Good Friday
|
128
|
+
Time.new(2019, 4, 22, 0, 0, 0, 43200), # Easter Monday
|
129
|
+
Time.new(2019, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
130
|
+
Time.new(2019, 6, 3, 0, 0, 0, 43200), # Queen's Birthday
|
131
|
+
Time.new(2019, 10, 28, 0, 0, 0, 46800), # Labour Day
|
132
|
+
Time.new(2019, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
133
|
+
Time.new(2019, 12, 26, 0, 0, 0, 46800), # Boxing Day
|
134
|
+
Time.new(2020, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
135
|
+
Time.new(2020, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day
|
136
|
+
Time.new(2020, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
137
|
+
Time.new(2020, 4, 10, 0, 0, 0, 43200), # Good Friday
|
138
|
+
Time.new(2020, 4, 13, 0, 0, 0, 43200), # Easter Monday
|
139
|
+
Time.new(2020, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
140
|
+
Time.new(2020, 4, 27, 0, 0, 0, 43200), # ANZAC Day (Mondayised)
|
141
|
+
Time.new(2020, 6, 1, 0, 0, 0, 43200), # Queen's Birthday
|
142
|
+
Time.new(2020, 10, 26, 0, 0, 0, 46800), # Labour Day
|
143
|
+
Time.new(2020, 12, 25, 0, 0, 0, 46800), # Christmas Day
|
144
|
+
Time.new(2020, 12, 26, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would normally work on Saturday)
|
145
|
+
Time.new(2020, 12, 28, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would not normally work on Saturday)
|
146
|
+
Time.new(2021, 1, 1, 0, 0, 0, 46800), # New Year's Day
|
147
|
+
Time.new(2021, 1, 2, 0, 0, 0, 46800), # Day after New Year's Day (Public Holiday for employees who would normally work on Saturday)
|
148
|
+
Time.new(2021, 1, 4, 0, 0, 0, 46800), # Day after New Year's Day (Public Holiday for employees who would not normally work on Saturday)
|
149
|
+
Time.new(2021, 2, 6, 0, 0, 0, 46800), # Waitangi Day
|
150
|
+
Time.new(2021, 2, 8, 0, 0, 0, 46800), # Waitangi Day (Mondayised)
|
151
|
+
Time.new(2021, 4, 2, 0, 0, 0, 46800), # Good Friday
|
152
|
+
Time.new(2021, 4, 5, 0, 0, 0, 43200), # Easter Monday
|
153
|
+
Time.new(2021, 4, 25, 0, 0, 0, 43200), # ANZAC Day
|
154
|
+
Time.new(2021, 4, 26, 0, 0, 0, 43200), # ANZAC Day (Mondayised)
|
155
|
+
Time.new(2021, 6, 7, 0, 0, 0, 43200), # Queen's Birthday
|
156
|
+
Time.new(2021, 10, 25, 0, 0, 0, 46800), # Labour Day
|
157
|
+
Time.new(2021, 12, 25, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would normally work on Saturday)
|
158
|
+
Time.new(2021, 12, 26, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would normally work on Sunday)
|
159
|
+
Time.new(2021, 12, 27, 0, 0, 0, 46800), # Christmas Day (Public Holiday for employees who would not normally work on Saturday)
|
160
|
+
Time.new(2021, 12, 28, 0, 0, 0, 46800), # Boxing Day (Public Holiday for employees who would not normally work on Sunday)
|
161
|
+
]
|
162
|
+
|
163
|
+
ANNIVERSARIES = [
|
164
|
+
Time.new(2008, 12, 1, 0, 0, 0, 46800), # Westland Anniversary Day
|
165
|
+
Time.new(2008, 12, 1, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
166
|
+
Time.new(2009, 1, 19, 0, 0, 0, 46800), # Wellington Anniversary Day
|
167
|
+
Time.new(2009, 1, 19, 0, 0, 0, 46800), # Southland Anniversary Day
|
168
|
+
Time.new(2009, 1, 26, 0, 0, 0, 46800), # Auckland Anniversary Day
|
169
|
+
Time.new(2009, 2, 2, 0, 0, 0, 46800), # Nelson Anniversary Day
|
170
|
+
Time.new(2009, 3, 9, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
171
|
+
Time.new(2009, 3, 23, 0, 0, 0, 46800), # Otago Anniversary Day
|
172
|
+
Time.new(2009, 9, 28, 0, 0, 0, 46800), # South Canterbury Anniversary Day
|
173
|
+
Time.new(2009, 10, 23, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
174
|
+
Time.new(2009, 11, 2, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
175
|
+
Time.new(2009, 11, 13, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
176
|
+
Time.new(2009, 11, 30, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
177
|
+
Time.new(2009, 11, 30, 0, 0, 0, 46800), # Westland Anniversary Day
|
178
|
+
Time.new(2010, 1, 18, 0, 0, 0, 46800), # Southland Anniversary Day
|
179
|
+
Time.new(2010, 1, 25, 0, 0, 0, 46800), # Wellington Anniversary Day
|
180
|
+
Time.new(2010, 2, 1, 0, 0, 0, 46800), # Auckland Anniversary Day
|
181
|
+
Time.new(2010, 2, 1, 0, 0, 0, 46800), # Nelson Anniversary Day
|
182
|
+
Time.new(2010, 3, 8, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
183
|
+
Time.new(2010, 3, 22, 0, 0, 0, 46800), # Otago Anniversary Day
|
184
|
+
Time.new(2010, 9, 27, 0, 0, 0, 46800), # South Canterbury Anniversary Day
|
185
|
+
Time.new(2010, 10, 22, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
186
|
+
Time.new(2010, 11, 1, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
187
|
+
Time.new(2010, 11, 12, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
188
|
+
Time.new(2010, 11, 29, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
189
|
+
Time.new(2010, 11, 29, 0, 0, 0, 46800), # Westland Anniversary Day
|
190
|
+
Time.new(2011, 1, 17, 0, 0, 0, 46800), # Southland Anniversary Day
|
191
|
+
Time.new(2011, 1, 24, 0, 0, 0, 46800), # Wellington Anniversary Day
|
192
|
+
Time.new(2011, 1, 31, 0, 0, 0, 46800), # Nelson Anniversary Day
|
193
|
+
Time.new(2011, 1, 31, 0, 0, 0, 46800), # Auckland Anniversary Day
|
194
|
+
Time.new(2011, 3, 14, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
195
|
+
Time.new(2011, 3, 21, 0, 0, 0, 46800), # Otago Anniversary Day
|
196
|
+
Time.new(2011, 9, 26, 0, 0, 0, 46800), # South Canterbury Anniversary Day
|
197
|
+
Time.new(2011, 10, 21, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
198
|
+
Time.new(2011, 10, 31, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
199
|
+
Time.new(2011, 11, 11, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
200
|
+
Time.new(2011, 11, 28, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
201
|
+
Time.new(2011, 12, 5, 0, 0, 0, 46800), # Westland Anniversary Day
|
202
|
+
Time.new(2012, 1, 16, 0, 0, 0, 46800), # Southland Anniversary Day
|
203
|
+
Time.new(2012, 1, 23, 0, 0, 0, 46800), # Wellington Anniversary Day
|
204
|
+
Time.new(2012, 1, 30, 0, 0, 0, 46800), # Auckland Anniversary Day
|
205
|
+
Time.new(2012, 1, 30, 0, 0, 0, 46800), # Nelson Anniversary Day
|
206
|
+
Time.new(2012, 3, 12, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
207
|
+
Time.new(2012, 3, 26, 0, 0, 0, 46800), # Otago Anniversary Day
|
208
|
+
Time.new(2012, 9, 24, 0, 0, 0, 43200), # South Canterbury Anniversary Day
|
209
|
+
Time.new(2012, 10, 19, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
210
|
+
Time.new(2012, 10, 29, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
211
|
+
Time.new(2012, 11, 16, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
212
|
+
Time.new(2012, 12, 3, 0, 0, 0, 46800), # Westland Anniversary Day
|
213
|
+
Time.new(2012, 12, 3, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
214
|
+
Time.new(2013, 1, 21, 0, 0, 0, 46800), # Wellington Anniversary Day
|
215
|
+
Time.new(2013, 1, 21, 0, 0, 0, 46800), # Southland Anniversary Day
|
216
|
+
Time.new(2013, 1, 28, 0, 0, 0, 46800), # Auckland Anniversary Day
|
217
|
+
Time.new(2013, 2, 4, 0, 0, 0, 46800), # Nelson Anniversary Day
|
218
|
+
Time.new(2013, 3, 11, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
219
|
+
Time.new(2013, 3, 25, 0, 0, 0, 46800), # Otago Anniversary Day
|
220
|
+
Time.new(2013, 9, 23, 0, 0, 0, 43200), # South Canterbury Anniversary Day
|
221
|
+
Time.new(2013, 10, 25, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
222
|
+
Time.new(2013, 11, 4, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
223
|
+
Time.new(2013, 11, 15, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
224
|
+
Time.new(2013, 12, 2, 0, 0, 0, 46800), # Westland Anniversary Day
|
225
|
+
Time.new(2013, 12, 2, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
226
|
+
Time.new(2014, 1, 20, 0, 0, 0, 46800), # Wellington Anniversary Day
|
227
|
+
Time.new(2014, 1, 27, 0, 0, 0, 46800), # Auckland Anniversary Day
|
228
|
+
Time.new(2014, 2, 3, 0, 0, 0, 46800), # Nelson Anniversary Day
|
229
|
+
Time.new(2014, 3, 10, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
230
|
+
Time.new(2014, 3, 24, 0, 0, 0, 46800), # Otago Anniversary Day
|
231
|
+
Time.new(2014, 4, 22, 0, 0, 0, 43200), # Southland Anniversary Day
|
232
|
+
Time.new(2014, 9, 22, 0, 0, 0, 43200), # South Canterbury Anniversary Day
|
233
|
+
Time.new(2014, 10, 24, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
234
|
+
Time.new(2014, 11, 3, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
235
|
+
Time.new(2014, 11, 14, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
236
|
+
Time.new(2014, 12, 1, 0, 0, 0, 46800), # Westland Anniversary Day
|
237
|
+
Time.new(2014, 12, 1, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
238
|
+
Time.new(2015, 1, 19, 0, 0, 0, 46800), # Wellington Anniversary Day
|
239
|
+
Time.new(2015, 1, 26, 0, 0, 0, 46800), # Auckland Anniversary Day
|
240
|
+
Time.new(2015, 2, 2, 0, 0, 0, 46800), # Nelson Anniversary Day
|
241
|
+
Time.new(2015, 3, 9, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
242
|
+
Time.new(2015, 3, 23, 0, 0, 0, 46800), # Otago Anniversary Day
|
243
|
+
Time.new(2015, 4, 7, 0, 0, 0, 43200), # Southland Anniversary Day
|
244
|
+
Time.new(2015, 9, 28, 0, 0, 0, 46800), # South Canterbury Anniversary Day
|
245
|
+
Time.new(2015, 10, 23, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
246
|
+
Time.new(2015, 11, 2, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
247
|
+
Time.new(2015, 11, 13, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
248
|
+
Time.new(2015, 11, 30, 0, 0, 0, 46800), # Westland Anniversary Day
|
249
|
+
Time.new(2015, 11, 30, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
250
|
+
Time.new(2016, 1, 25, 0, 0, 0, 46800), # Wellington Anniversary Day
|
251
|
+
Time.new(2016, 2, 1, 0, 0, 0, 46800), # Nelson Anniversary Day
|
252
|
+
Time.new(2016, 2, 1, 0, 0, 0, 46800), # Auckland Anniversary Day
|
253
|
+
Time.new(2016, 3, 14, 0, 0, 0, 46800), # Taranaki Anniversary Day
|
254
|
+
Time.new(2016, 3, 21, 0, 0, 0, 46800), # Otago Anniversary Day
|
255
|
+
Time.new(2016, 3, 29, 0, 0, 0, 46800), # Southland Anniversary Day
|
256
|
+
Time.new(2016, 9, 26, 0, 0, 0, 46800), # South Canterbury Anniversary Day
|
257
|
+
Time.new(2016, 10, 21, 0, 0, 0, 46800), # Hawkes' Bay Anniversary Day
|
258
|
+
Time.new(2016, 10, 31, 0, 0, 0, 46800), # Marlborough Anniversary Day
|
259
|
+
Time.new(2016, 11, 11, 0, 0, 0, 46800), # Canterbury Anniversary Day
|
260
|
+
Time.new(2016, 11, 28, 0, 0, 0, 46800), # Westland Anniversary Day
|
261
|
+
Time.new(2016, 11, 28, 0, 0, 0, 46800), # Chatham Islands Anniversary Day
|
262
|
+
Time.new(2017, 1, 23, 0, 0, 0, 46800), # Wellington Anniversary
|
263
|
+
Time.new(2017, 1, 30, 0, 0, 0, 46800), # Auckland Anniversary
|
264
|
+
Time.new(2017, 1, 30, 0, 0, 0, 46800), # Nelson Anniversary
|
265
|
+
Time.new(2017, 3, 13, 0, 0, 0, 46800), # Taranaki Anniversary
|
266
|
+
Time.new(2017, 3, 20, 0, 0, 0, 46800), # Otago Anniversary
|
267
|
+
Time.new(2017, 4, 18, 0, 0, 0, 43200), # Southland Anniversary
|
268
|
+
Time.new(2017, 9, 25, 0, 0, 0, 46800), # Canterbury (South) Anniversary
|
269
|
+
Time.new(2017, 10, 20, 0, 0, 0, 46800), # Hawke's Bay Anniversary
|
270
|
+
Time.new(2017, 10, 30, 0, 0, 0, 46800), # Marlborough Anniversary
|
271
|
+
Time.new(2017, 11, 17, 0, 0, 0, 46800), # Canterbury Anniversary
|
272
|
+
Time.new(2017, 11, 27, 0, 0, 0, 46800), # Chatham Islands Anniversary
|
273
|
+
Time.new(2017, 12, 4, 0, 0, 0, 46800), # Westland Anniversary
|
274
|
+
Time.new(2018, 1, 22, 0, 0, 0, 46800), # Wellington Anniversary
|
275
|
+
Time.new(2018, 1, 29, 0, 0, 0, 46800), # Nelson Anniversary
|
276
|
+
Time.new(2018, 1, 29, 0, 0, 0, 46800), # Auckland Anniversary
|
277
|
+
Time.new(2018, 3, 12, 0, 0, 0, 46800), # Taranaki Anniversary
|
278
|
+
Time.new(2018, 3, 26, 0, 0, 0, 46800), # Otago Anniversary
|
279
|
+
Time.new(2018, 4, 3, 0, 0, 0, 43200), # Southland Anniversary
|
280
|
+
Time.new(2018, 9, 24, 0, 0, 0, 43200), # Canterbury (South) Anniversary
|
281
|
+
Time.new(2018, 10, 19, 0, 0, 0, 46800), # Hawke's Bay Anniversary
|
282
|
+
Time.new(2018, 10, 29, 0, 0, 0, 46800), # Marlborough Anniversary
|
283
|
+
Time.new(2018, 11, 16, 0, 0, 0, 46800), # Canterbury Anniversary
|
284
|
+
Time.new(2018, 12, 3, 0, 0, 0, 46800), # Chatham Islands Anniversary
|
285
|
+
Time.new(2018, 12, 3, 0, 0, 0, 46800), # Westland Anniversary
|
286
|
+
Time.new(2019, 1, 21, 0, 0, 0, 46800), # Wellington Anniversary
|
287
|
+
Time.new(2019, 1, 28, 0, 0, 0, 46800), # Auckland Anniversary
|
288
|
+
Time.new(2019, 2, 4, 0, 0, 0, 46800), # Nelson Anniversary
|
289
|
+
Time.new(2019, 3, 11, 0, 0, 0, 46800), # Taranaki Anniversary
|
290
|
+
Time.new(2019, 3, 25, 0, 0, 0, 46800), # Otago Anniversary
|
291
|
+
Time.new(2019, 4, 23, 0, 0, 0, 43200), # Southland Anniversary
|
292
|
+
Time.new(2019, 9, 23, 0, 0, 0, 43200), # Canterbury (South) Anniversary
|
293
|
+
Time.new(2019, 10, 25, 0, 0, 0, 46800), # Hawke's Bay Anniversary
|
294
|
+
Time.new(2019, 11, 4, 0, 0, 0, 46800), # Marlborough Anniversary
|
295
|
+
Time.new(2019, 11, 15, 0, 0, 0, 46800), # Canterbury Anniversary
|
296
|
+
Time.new(2019, 12, 2, 0, 0, 0, 46800), # Chatham Islands Anniversary
|
297
|
+
Time.new(2019, 12, 2, 0, 0, 0, 46800), # Westland Anniversary
|
298
|
+
Time.new(2020, 1, 20, 0, 0, 0, 46800), # Wellington Anniversary
|
299
|
+
Time.new(2020, 1, 27, 0, 0, 0, 46800), # Auckland Anniversary
|
300
|
+
Time.new(2020, 2, 3, 0, 0, 0, 46800), # Nelson Anniversary
|
301
|
+
Time.new(2020, 3, 9, 0, 0, 0, 46800), # Taranaki Anniversary
|
302
|
+
Time.new(2020, 3, 23, 0, 0, 0, 46800), # Otago Anniversary
|
303
|
+
Time.new(2020, 4, 14, 0, 0, 0, 43200), # Southland Anniversary
|
304
|
+
Time.new(2020, 9, 28, 0, 0, 0, 46800), # Canterbury (South) Anniversary
|
305
|
+
Time.new(2020, 10, 23, 0, 0, 0, 46800), # Hawke's Bay Anniversary
|
306
|
+
Time.new(2020, 11, 2, 0, 0, 0, 46800), # Marlborough Anniversary
|
307
|
+
Time.new(2020, 11, 13, 0, 0, 0, 46800), # Canterbury Anniversary
|
308
|
+
Time.new(2020, 11, 30, 0, 0, 0, 46800), # Chatham Islands Anniversary
|
309
|
+
Time.new(2020, 11, 30, 0, 0, 0, 46800), # Westland Anniversary
|
310
|
+
Time.new(2021, 1, 25, 0, 0, 0, 46800), # Wellington Anniversary
|
311
|
+
Time.new(2021, 2, 1, 0, 0, 0, 46800), # Nelson Anniversary
|
312
|
+
Time.new(2021, 2, 1, 0, 0, 0, 46800), # Auckland Anniversary
|
313
|
+
Time.new(2021, 3, 8, 0, 0, 0, 46800), # Taranaki Anniversary
|
314
|
+
Time.new(2021, 3, 22, 0, 0, 0, 46800), # Otago Anniversary
|
315
|
+
Time.new(2021, 4, 6, 0, 0, 0, 43200), # Southland Anniversary
|
316
|
+
Time.new(2021, 9, 27, 0, 0, 0, 46800), # Canterbury (South) Anniversary
|
317
|
+
Time.new(2021, 10, 22, 0, 0, 0, 46800), # Hawke's Bay Anniversary
|
318
|
+
Time.new(2021, 11, 1, 0, 0, 0, 46800), # Marlborough Anniversary
|
319
|
+
Time.new(2021, 11, 12, 0, 0, 0, 46800), # Canterbury Anniversary
|
320
|
+
Time.new(2021, 11, 29, 0, 0, 0, 46800), # Chatham Islands Anniversary
|
321
|
+
Time.new(2021, 11, 29, 0, 0, 0, 46800), # Westland Anniversary
|
322
|
+
]
|
323
|
+
|
324
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Nzholidays
|
2
|
+
|
3
|
+
NZ_TIME_ZONE = TZInfo::Timezone.get('Pacific/Auckland')
|
4
|
+
|
5
|
+
# Returns a Time object representing the start of a day in NZST
|
6
|
+
# GMT offset takes into account Daylight Savings Time, i.e. is +1200 or +1300
|
7
|
+
def self.nz_time(year, month, day)
|
8
|
+
|
9
|
+
# Holiday starts at the beginning of the given day
|
10
|
+
time = ::Time.new(year, month, day, 0, 0, 0)
|
11
|
+
|
12
|
+
# Find the UTC total offset (daylight savings or standard time) for time
|
13
|
+
|
14
|
+
# note period_for_local ignores timezone info in the time object
|
15
|
+
# http://www.rubydoc.info/gems/tzinfo/TZInfo/Timezone#period_for_local-instance_method
|
16
|
+
|
17
|
+
utc_total_offset = NZ_TIME_ZONE.period_for_local(time).utc_total_offset
|
18
|
+
|
19
|
+
time.getlocal(utc_total_offset)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns true if the given date is a national public holiday in NZ
|
23
|
+
def self.nz_public_holiday?(query)
|
24
|
+
!!HOLIDAYS.find do |hol|
|
25
|
+
hol.year == query.year && hol.month == query.month && hol.day == query.day
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns true if the given date is a regional anniversary holiday somewhere in NZ
|
30
|
+
def self.nz_anniversary?(query)
|
31
|
+
!!ANNIVERSARIES.find do |hol|
|
32
|
+
hol.year == query.year && hol.month == query.month && hol.day == query.day
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/nzholidays/template.erb
CHANGED
@@ -1,55 +1,16 @@
|
|
1
|
-
<%
|
2
|
-
require "bundler/setup"
|
3
|
-
|
4
|
-
require 'open-uri'
|
5
|
-
require 'net/http'
|
6
|
-
require 'icalendar'
|
7
|
-
require 'tzinfo'
|
8
|
-
|
9
|
-
SOURCE_URL = 'http://apps.employment.govt.nz/ical/public-holidays-all.ics'
|
10
|
-
FILE='holidays.ics'
|
11
|
-
|
12
|
-
# Download the ICS file
|
13
|
-
open(FILE, 'wb') do |file|
|
14
|
-
file << open(SOURCE_URL).read
|
15
|
-
end
|
16
|
-
|
17
|
-
cal_file = File.open(FILE)
|
18
|
-
calendars = Icalendar::Calendar.parse(cal_file)
|
19
|
-
|
20
|
-
-%>
|
21
1
|
# Auto-generated at <%= Time.now %>
|
22
|
-
# Do not edit - see template
|
2
|
+
# Do not edit - see template <%= __FILE__ %>
|
23
3
|
# To regenerate, `bundle exec rake generate`
|
24
4
|
|
25
|
-
require "nzholidays/version"
|
26
|
-
require 'time'
|
27
|
-
require 'tzinfo'
|
28
|
-
|
29
5
|
module Nzholidays
|
30
6
|
|
31
|
-
NZ_TIME_ZONE = TZInfo::Timezone.get('Pacific/Auckland')
|
32
|
-
|
33
|
-
def self.nz_time(year, month, day)
|
34
|
-
|
35
|
-
# Holiday starts at the beginning of the given day
|
36
|
-
time = ::Time.new(year, month, day, 0, 0, 0)
|
37
|
-
|
38
|
-
# Find the UTC total offset (daylight savings or standard time) for time
|
39
|
-
|
40
|
-
# note period_for_local ignores timezone info in the time object
|
41
|
-
# http://www.rubydoc.info/gems/tzinfo/TZInfo/Timezone#period_for_local-instance_method
|
42
|
-
|
43
|
-
utc_total_offset = NZ_TIME_ZONE.period_for_local(time).utc_total_offset
|
44
|
-
|
45
|
-
time.getlocal(utc_total_offset)
|
46
|
-
end
|
47
|
-
|
48
7
|
HOLIDAYS = [
|
49
8
|
<% calendars.each do |calendar|
|
50
|
-
calendar.events.select {|e| !e.summary.match(/Anniversary/i) }.
|
51
|
-
|
52
|
-
nz_time(
|
9
|
+
events = calendar.events.select {|e| !e.summary.match(/Anniversary/i) }.sort {|a,b| a.dtstart <=> b.dtstart }
|
10
|
+
events.each do |event|
|
11
|
+
time = Nzholidays.nz_time(event.dtstart.year, event.dtstart.month, event.dtstart.day)
|
12
|
+
-%>
|
13
|
+
Time.new(<%= time.year %>, <%= time.month %>, <%= time.day %>, <%= time.hour %>, <%= time.min %>, <%= time.sec %>, <%= time.gmt_offset %>), # <%= event.summary %>
|
53
14
|
<%
|
54
15
|
end
|
55
16
|
end
|
@@ -58,25 +19,15 @@ module Nzholidays
|
|
58
19
|
|
59
20
|
ANNIVERSARIES = [
|
60
21
|
<% calendars.each do |calendar|
|
61
|
-
calendar.events.select {|e| !!e.summary.match(/Anniversary/i) }.
|
22
|
+
events = calendar.events.select {|e| !!e.summary.match(/Anniversary/i) }.sort {|a,b| a.dtstart <=> b.dtstart }
|
23
|
+
events.each do |event|
|
24
|
+
time = Nzholidays.nz_time(event.dtstart.year, event.dtstart.month, event.dtstart.day)
|
62
25
|
-%>
|
63
|
-
|
26
|
+
Time.new(<%= time.year %>, <%= time.month %>, <%= time.day %>, <%= time.hour %>, <%= time.min %>, <%= time.sec %>, <%= time.gmt_offset %>), # <%= event.summary %>
|
64
27
|
<%
|
65
28
|
end
|
66
29
|
end
|
67
30
|
-%>
|
68
31
|
]
|
69
32
|
|
70
|
-
def self.nz_public_holiday?(query)
|
71
|
-
!!HOLIDAYS.find do |hol|
|
72
|
-
hol.year == query.year && hol.month == query.month && hol.day == query.day
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.nz_anniversary?(query)
|
77
|
-
!!ANNIVERSARIES.find do |hol|
|
78
|
-
hol.year == query.year && hol.month == query.month && hol.day == query.day
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
33
|
end
|
data/lib/nzholidays/version.rb
CHANGED
data/nzholidays.gemspec
CHANGED
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "tzinfo"
|
24
|
+
spec.add_dependency "tzinfo", "~> 1.2.5"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler",
|
27
|
-
spec.add_development_dependency "rake",
|
28
|
-
spec.add_development_dependency "rspec",
|
29
|
-
spec.add_development_dependency "icalendar", "
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.5.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.8.0"
|
29
|
+
spec.add_development_dependency "icalendar", "~> 2.4.0"
|
30
30
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nzholidays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Douglas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzinfo
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.2.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.2.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,42 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 10.5.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 10.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.8.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.8.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: icalendar
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.4.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.4.0
|
83
83
|
description: New Zealand Public Holidays
|
84
84
|
email:
|
85
85
|
- 105003+carld@users.noreply.github.com
|
@@ -98,6 +98,8 @@ files:
|
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
100
|
- lib/nzholidays.rb
|
101
|
+
- lib/nzholidays/calendar.rb
|
102
|
+
- lib/nzholidays/nztime.rb
|
101
103
|
- lib/nzholidays/template.erb
|
102
104
|
- lib/nzholidays/version.rb
|
103
105
|
- nzholidays.gemspec
|