Module: Holidays::Definition::CustomMethods::AU

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

Overview

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

Class Method Summary collapse

Class Method Details

.afl_grand_final(year) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/holidays/definition/custom_methods/au.rb', line 10

def afl_grand_final(year)
  case year
  when 2015
    Date.civil(2015, 10, 2)
  when 2016
    Date.civil(2016, 9, 30)
  when 2017
    Date.civil(2017, 9, 29)
  when 2020
    Date.civil(2020, 10, 23)
  when 2022
    Date.civil(2022, 9, 23)
  else
    # Friday before AFL Grand Final typically falls on the last Friday in September
    # Override when falls on a different date
    last_day = Date.civil(year, 9, -1)
    last_friday = last_day - ((last_day.wday - 5) % 7)
    last_friday
  end
end

.hobart_show_day(year) ⇒ Object



51
52
53
54
# File 'lib/holidays/definition/custom_methods/au.rb', line 51

def hobart_show_day(year)
  fourth_sat_in_oct = Date.civil(year, 10, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 4, :saturday))
  fourth_sat_in_oct - 2 # the thursday before
end

.march_pub_hol_sa(year) ⇒ Object



56
57
58
# File 'lib/holidays/definition/custom_methods/au.rb', line 56

def march_pub_hol_sa(year)
  Date.civil(year, 3, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 3, :second, :monday))
end

.may_pub_hol_sa(year) ⇒ Object



60
61
62
# File 'lib/holidays/definition/custom_methods/au.rb', line 60

def may_pub_hol_sa(year)
  Date.civil(year, 5, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, :third, :monday))
end

.qld_brisbane_ekka_holiday(year) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/holidays/definition/custom_methods/au.rb', line 64

def qld_brisbane_ekka_holiday(year)
  first_friday = Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 8, :first, :friday)

  if first_friday < 5
    second_friday = Date.civil(year, 8, Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 8, :second, :friday))
    second_friday + 5 # The next Wednesday
  else
    Date.civil(year, 8, first_friday) + 5
  end
end

.qld_kings_bday_october(year) ⇒ Object



35
36
37
# File 'lib/holidays/definition/custom_methods/au.rb', line 35

def qld_kings_bday_october(year)
  Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
end

.qld_labour_day_may(year) ⇒ Object



43
44
45
# File 'lib/holidays/definition/custom_methods/au.rb', line 43

def qld_labour_day_may(year)
  Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 5, 1, 1)
end

.qld_labour_day_october(year) ⇒ Object



47
48
49
# File 'lib/holidays/definition/custom_methods/au.rb', line 47

def qld_labour_day_october(year)
  Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
end

.qld_queens_bday_october(year) ⇒ Object



31
32
33
# File 'lib/holidays/definition/custom_methods/au.rb', line 31

def qld_queens_bday_october(year)
  Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 10, 1, 1)
end

.qld_queens_birthday_june(year) ⇒ Object



39
40
41
# File 'lib/holidays/definition/custom_methods/au.rb', line 39

def qld_queens_birthday_june(year)
  Holidays::Factory::DateCalculator.day_of_month_calculator.call(year, 6, 2, 1)
end

.to_nearest_monday_after(date) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/holidays/definition/custom_methods/au.rb', line 75

def to_nearest_monday_after(date)
  case date.wday
  when 6
    date += 2
  when 5
    date += 3
  when 4
    date += 4
  when 3
    date += 5
  when 2
    date += 6
  when 0
    date += 1
  end
  date
end