Module: Holidays::Definition::CustomMethods::NZ

Defined in:
lib/holidays/definition/custom_methods/nz.rb

Overview

nz custom holiday calculations, ported verbatim from the methods: block in definitions/nz.yaml.

Class Method Summary collapse

Class Method Details

.closest_monday(date) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/holidays/definition/custom_methods/nz.rb', line 10

def closest_monday(date)
  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
end

.matariki(year) ⇒ Object



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
# File 'lib/holidays/definition/custom_methods/nz.rb', line 37

def matariki(year)
  @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]
end

.next_week(date) ⇒ Object



25
26
27
# File 'lib/holidays/definition/custom_methods/nz.rb', line 25

def next_week(date)
  date + 7
end

.nz_canterbury_anniversary(year) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/holidays/definition/custom_methods/nz.rb', line 29

def nz_canterbury_anniversary(year)
  date = Date.civil(year, 11, 1)
  date += 1 until date.tuesday?
  date += 1
  date += 1 until date.friday?
  date + 7
end

.previous_friday(date) ⇒ Object



21
22
23
# File 'lib/holidays/definition/custom_methods/nz.rb', line 21

def previous_friday(date)
  date - 3
end