Module: Holidays

Defined in:
lib/holidays.rb,
lib/holidays/version.rb,
lib/holidays/option_factory.rb,
lib/generated_definitions/ar.rb,
lib/generated_definitions/at.rb,
lib/generated_definitions/au.rb,
lib/generated_definitions/be.rb,
lib/generated_definitions/bg.rb,
lib/generated_definitions/br.rb,
lib/generated_definitions/ca.rb,
lib/generated_definitions/ch.rb,
lib/generated_definitions/cl.rb,
lib/generated_definitions/cr.rb,
lib/generated_definitions/cz.rb,
lib/generated_definitions/de.rb,
lib/generated_definitions/dk.rb,
lib/generated_definitions/el.rb,
lib/generated_definitions/es.rb,
lib/generated_definitions/fi.rb,
lib/generated_definitions/fr.rb,
lib/generated_definitions/gb.rb,
lib/generated_definitions/hr.rb,
lib/generated_definitions/hu.rb,
lib/generated_definitions/ie.rb,
lib/generated_definitions/is.rb,
lib/generated_definitions/it.rb,
lib/generated_definitions/jp.rb,
lib/generated_definitions/li.rb,
lib/generated_definitions/lt.rb,
lib/generated_definitions/ma.rb,
lib/generated_definitions/mx.rb,
lib/generated_definitions/nl.rb,
lib/generated_definitions/no.rb,
lib/generated_definitions/nz.rb,
lib/generated_definitions/ph.rb,
lib/generated_definitions/pl.rb,
lib/generated_definitions/pt.rb,
lib/generated_definitions/ro.rb,
lib/generated_definitions/se.rb,
lib/generated_definitions/sg.rb,
lib/generated_definitions/si.rb,
lib/generated_definitions/sk.rb,
lib/generated_definitions/us.rb,
lib/generated_definitions/ve.rb,
lib/generated_definitions/vi.rb,
lib/generated_definitions/za.rb,
lib/generated_definitions/ups.rb,
lib/holidays/use_case_factory.rb,
lib/generated_definitions/nerc.rb,
lib/generated_definitions/nyse.rb,
lib/holidays/definition_factory.rb,
lib/generated_definitions/europe.rb,
lib/generated_definitions/fed_ex.rb,
lib/generated_definitions/REGIONS.rb,
lib/holidays/core_extensions/date.rb,
lib/holidays/date_calculator/easter.rb,
lib/generated_definitions/ecb_target.rb,
lib/holidays/date_calculator_factory.rb,
lib/generated_definitions/scandinavia.rb,
lib/holidays/use_case/context/between.rb,
lib/holidays/definition/context/merger.rb,
lib/generated_definitions/north_america.rb,
lib/generated_definitions/united_nations.rb,
lib/holidays/definition/repository/cache.rb,
lib/holidays/definition/validator/region.rb,
lib/generated_definitions/federal_reserve.rb,
lib/holidays/date_calculator/day_of_month.rb,
lib/holidays/definition/context/generator.rb,
lib/holidays/option/context/parse_options.rb,
lib/holidays/definition/repository/regions.rb,
lib/holidays/date_calculator/weekend_modifier.rb,
lib/holidays/definition/repository/proc_cache.rb,
lib/holidays/use_case/context/dates_driver_builder.rb,
lib/holidays/definition/repository/holidays_by_month.rb

Overview

This context builds a hash that contains => [<array of months>]. The idea is that we will iterate over each year and then over each month internally and check to see if the supplied dates match any holidays for the region and date. So if we supply start_date of 2015/1/1 and end_date of 2015/6/1 then we will return a date driver of => [0, 1, 2, 5, 6, 7]. In the logic in the ‘between’ use case we will iterate over this and compare dates in these months to the supplied range to determine whether they should be returned to the user.

Defined Under Namespace

Modules: AR, AT, AU, BE, BG, BR, CA, CH, CL, CR, CZ, CoreExtensions, DE, DK, DateCalculator, DateCalculatorFactory, Definition, DefinitionFactory, ECB_TARGET, EL, ES, EUROPE, FEDERAL_RESERVE, FED_EX, FI, FR, GB, HR, HU, IE, IS, IT, JP, LI, LT, MA, MX, NERC, NL, NO, NORTH_AMERICA, NYSE, NZ, Option, OptionFactory, PH, PL, PT, RO, SCANDINAVIA, SE, SG, SI, SK, UNITED_NATIONS, UPS, US, UseCase, VE, VI, ZA Classes: UnknownRegionError, UseCaseFactory

Constant Summary collapse

WEEKS =
{:first => 1, :second => 2, :third => 3, :fourth => 4, :fifth => 5, :last => -1, :second_last => -2, :third_last => -3}
MONTH_LENGTHS =
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
DAY_SYMBOLS =
Date::DAYNAMES.collect { |n| n.downcase.intern }
DEFINITIONS_PATH =
'generated_definitions'
FULL_DEFINITIONS_PATH =
File.expand_path(File.dirname(__FILE__) + "/#{DEFINITIONS_PATH}")
VERSION =
'3.2.0'
REGIONS =
[:ar, :at, :au, :au_nsw, :au_vic, :au_qld, :au_nt, :au_act, :au_sa, :au_tas_south, :au_wa, :au_tas, :au_qld_cairns, :au_qld_brisbane, :au_tas_north, :au_vic_melbourne, :be, :br, :bg_en, :bg_bg, :ca, :ca_qc, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_ns, :ca_pe, :ca_bc, :ca_nf, :ca_nt, :ca_nu, :ca_nb, :ca_yk, :us, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cl, :cr, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_st, :de_by_aux, :de_bb, :de_mv, :de_sn, :de_th, :ecb_target, :el, :es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es, :es_ct, :es_v, :es_vc, :federal_reserve, :fedex, :fi, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :ie, :is, :it, :li, :lt, :ma, :mx, :mx_pue, :us, :ca, :nerc, :nl, :no, :nyse, :nz, :nz_sl, :nz_we, :nz_ak, :nz_nl, :nz_ne, :nz_ot, :nz_ta, :nz_sc, :nz_hb, :nz_mb, :nz_ca, :nz_ch, :nz_wl, :ph, :pl, :pt, :ro, :se, :us, :us_dc, :us_ca, :ca, :united_nations, :ups, :za, :ca, :ca_qc, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_ns, :ca_pe, :ca_bc, :ca_nf, :ca_nt, :ca_nu, :ca_nb, :ca_yk, :mx, :mx_pue, :us, :us_dc, :us_ca, :dk, :is, :no, :se, :fi, :at, :be, :ch_zh, :ch_be, :ch_lu, :ch_ur, :ch_sz, :ch_ow, :ch_nw, :ch_gl, :ch_zg, :ch_fr, :ch_so, :ch_bs, :ch_bl, :ch_sh, :ch_ar, :ch_ai, :ch_sg, :ch_gr, :ch_ag, :ch_tg, :ch_ti, :ch_vd, :ch_ne, :ch_ge, :ch_ju, :ch_vs, :ch, :cz, :dk, :de, :de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_st, :de_by_aux, :de_bb, :de_mv, :de_sn, :de_th, :el, :es_pv, :es_na, :es_an, :es_ib, :es_cm, :es_mu, :es_m, :es_ar, :es_cl, :es_cn, :es_lo, :es_ga, :es_ce, :es_o, :es_ex, :es, :es_ct, :es_v, :es_vc, :fr, :gb, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :gb_con, :je, :gb_jsy, :gg, :gb_gsy, :im, :gb_iom, :hr, :hu, :ie, :is, :it, :li, :lt, :nl, :no, :pl, :pt, :ro, :sk, :si, :bg_en, :bg_bg, :jp, :ve, :vi, :sk, :si, :sg]

Class Method Summary collapse

Class Method Details

.afl_grand_final(year) ⇒ Object



60
61
62
63
64
# File 'lib/generated_definitions/au.rb', line 60

def self.afl_grand_final(year)
  if year == 2015
    Date.civil(2015, 10, 2)
  end
end

.available(full_path = false) ⇒ Object

Returns an array of symbols all the available holiday definitions.

Optional ‘full_path` param is used internally for loading all the definitions.



179
180
181
182
# File 'lib/holidays.rb', line 179

def available(full_path = false)
  paths = Dir.glob(FULL_DEFINITIONS_PATH + '/*.rb')
  full_path ? paths : paths.collect { |path| path.match(/([a-z_-]+)\.rb/i)[1].to_sym }
end

.between(start_date, end_date, *options) ⇒ Object

Get all holidays occuring between two dates, inclusively.

Returns an array of hashes or nil.

Each holiday is returned as a hash with the following fields:

start_date

Ruby Date object.

end_date

Ruby Date object.

options

One or more region symbols, :informal and/or :observed.

Example

from = Date.civil(2008,7,1)
to   = Date.civil(2008,7,31)

Holidays.between(from, to, :ca, :us)
=> [{:name => 'Canada Day', :regions => [:ca]...}
    {:name => 'Independence Day'', :regions => [:us], ...}]

Raises:

  • (ArgumentError)


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/holidays.rb', line 107

def between(start_date, end_date, *options)
  raise ArgumentError unless start_date && end_date

  # remove the timezone
  start_date = start_date.new_offset(0) + start_date.offset if start_date.respond_to?(:new_offset)
  end_date = end_date.new_offset(0) + end_date.offset if end_date.respond_to?(:new_offset)

  start_date, end_date = get_date(start_date), get_date(end_date)

  if cached_holidays = DefinitionFactory.cache_repository.find(start_date, end_date, options)
    return cached_holidays
  end

  regions, observed, informal = OptionFactory.parse_options.call(options)
  date_driver_hash = UseCaseFactory.dates_driver_builder.call(start_date, end_date)

  UseCaseFactory.between.call(start_date, end_date, date_driver_hash, regions, observed, informal)
end

.ca_victoria_day(year) ⇒ Object

Monday on or before May 24



66
67
68
69
70
71
72
73
74
# File 'lib/generated_definitions/ca.rb', line 66

def self.ca_victoria_day(year)
  date = Date.civil(year,5,24)
  if date.wday > 1
    date -= (date.wday - 1)
  elsif date.wday == 0
    date -= 6
  end
  date
end

.cache_between(start_date, end_date, *options) ⇒ Object

Allows a developer to explicitly calculate and cache holidays within a given period



127
128
129
130
131
132
# File 'lib/holidays.rb', line 127

def cache_between(start_date, end_date, *options)
  start_date, end_date = get_date(start_date), get_date(end_date)
  cache_data = between(start_date, end_date, *options)

  DefinitionFactory.cache_repository.cache_between(start_date, end_date, cache_data, options)
end

.calculate_day_of_month(year, month, day, wday) ⇒ Object



172
173
174
# File 'lib/holidays.rb', line 172

def calculate_day_of_month(year, month, day, wday)
  DateCalculatorFactory.day_of_month_calculator.call(year, month, day, wday)
end

.ch_ge_jeune_genevois(year) ⇒ Object

Thursday after the first Sunday of September



64
65
66
67
68
69
70
71
72
# File 'lib/generated_definitions/ch.rb', line 64

def self.ch_ge_jeune_genevois(year)
  date = Date.civil(year,9,1)
  # Find the first Sunday of September
  until date.wday.eql? 0 do
    date += 1
  end
  # Thursday is four days after Sunday
  date + 4
end

.ch_gl_naefelser_fahrt(year) ⇒ Object

First Thursday of April. If the first Thursday of April is in the week before easter, then a week later.



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/generated_definitions/ch.rb', line 76

def self.ch_gl_naefelser_fahrt(year)
  date = Date.civil(year,4,1)
  # Find the first Thursday of April
  until date.wday.eql? 4 do
    date += 1
  end
  if date.eql?(easter(year)-3)
    date += 7
  end
  date
end

.ch_vd_lundi_du_jeune_federal(year) ⇒ Object

Monday after the third Sunday of September



51
52
53
54
55
56
57
58
59
60
# File 'lib/generated_definitions/ch.rb', line 51

def self.ch_vd_lundi_du_jeune_federal(year)
  date = Date.civil(year,9,1)
  # Find the first Sunday of September
  until date.wday.eql? 0 do
    date += 1
  end
  # There are 15 days between the first Sunday
  # and the Monday after the third Sunday
  date + 15
end

.closest_monday(date) ⇒ Object



49
50
51
52
53
54
55
56
57
58
# File 'lib/generated_definitions/nz.rb', line 49

def self.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

.day_after_thanksgiving(year) ⇒ Object



55
56
57
# File 'lib/generated_definitions/us.rb', line 55

def self.day_after_thanksgiving(year)
  Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 11, 4, 4) + 1
end

.de_buss_und_bettag(year) ⇒ Object

Germany: Wednesday before November 23



42
43
44
45
46
47
48
49
50
# File 'lib/generated_definitions/de.rb', line 42

def self.de_buss_und_bettag(year)
  date = Date.civil(year,11,23)
  if date.wday > 3
    date -= (date.wday - 3)
  else
    date -= (date.wday + 4)
  end
  date
end

.easter(year) ⇒ Object



140
141
142
# File 'lib/holidays.rb', line 140

def easter(year)
  DateCalculatorFactory::Easter::Gregorian.easter_calculator.calculate_easter_for(year)
end

.fi_juhannusaatto(year) ⇒ Object

Finland: Mid-summer eve (Friday between June 19–25)



41
42
43
44
45
46
47
48
49
# File 'lib/generated_definitions/fi.rb', line 41

def self.fi_juhannusaatto(year)
  date = Date.civil(year,6,19)
  if date.wday > 5 #if 19.6 is saturday
    date += 6
  else 
    date += (5 - date.wday)
  end
  date
end

.fi_juhannuspaiva(year) ⇒ Object

Finland: Mid-summer (Saturday between June 20–26)



53
54
55
56
57
# File 'lib/generated_definitions/fi.rb', line 53

def self.fi_juhannuspaiva(year)
  date = Date.civil(year,6,20)
  date += (6 - date.wday)
  date
end

.fi_pyhainpaiva(year) ⇒ Object

Finland: All Saint’s Day (Saturday between Oct 31 and Nov 6)



61
62
63
64
65
# File 'lib/generated_definitions/fi.rb', line 61

def self.fi_pyhainpaiva(year)
  date = Date.civil(year,10,31)
  date += (6 - date.wday)
  date
end

.full_week?(date, *options) ⇒ Boolean

Does the given work-week have any holidays?

date

A Date object.

:options

One or more region symbols, and/or :informal. Automatically includes :observed. If you don’t want this, pass :no_observed

The given Date can be any day of the week. Returns true if any holidays fall on Monday - Friday of the given week.

Returns:

  • (Boolean)


81
82
83
84
85
86
87
88
89
# File 'lib/holidays.rb', line 81

def full_week?(date, *options)
  days_to_monday = date.wday - 1
  days_to_friday = 5 - date.wday
  start_date = date - days_to_monday
  end_date = date + days_to_friday
  options += [:observed] unless options.include?(:no_observed)
  options.delete(:no_observed)
  between(start_date, end_date, options).empty?
end

.g20_day_2014_only(year) ⇒ Object



90
91
92
# File 'lib/generated_definitions/au.rb', line 90

def self.g20_day_2014_only(year)
  year == 2014 ? 14 : nil
end

.hobart_show_day(year) ⇒ Object

worksafe.tas.gov.au/__data/assets/pdf_file/0008/287036/Public_Holidays_2014.pdf The Thursday before the fourth Saturday in October.



97
98
99
100
# File 'lib/generated_definitions/au.rb', line 97

def self.hobart_show_day(year)
  fourth_sat_in_oct = Date.civil(year, 10, Holidays.calculate_day_of_month(year, 10, 4, :saturday))
  fourth_sat_in_oct - 2 # the thursday before
end

.ie_st_stephens_day(date) ⇒ Object

Ireland - Stephens Day is always the day after christmas day



35
36
37
38
39
40
41
# File 'lib/generated_definitions/ie.rb', line 35

def self.ie_st_stephens_day(date)
  case date.wday
  when 6, 0 then date + 2
  when 1 then date + 1
  else date
  end
end

.is_sumardagurinn_fyrsti(year) ⇒ Object

Iceland: first day of summer (Thursday after 18 April)



52
53
54
55
56
57
58
59
60
# File 'lib/generated_definitions/is.rb', line 52

def self.is_sumardagurinn_fyrsti(year)
  date = Date.civil(year,4,18)
  if date.wday < 4
    date += (4 - date.wday)
  else date
    date += (11 - date.wday)
  end
  date
end

.jp_citizons_holiday(year) ⇒ Object



97
98
99
100
101
102
103
104
105
# File 'lib/generated_definitions/jp.rb', line 97

def self.jp_citizons_holiday(year)
  year < 2003 and return nil
  ncd = Holidays.jp_national_culture_day(year)
  if ncd.wday == 3
    ncd - 1
  else
    nil
  end
end

.jp_mountain_holiday(year) ⇒ Object



108
109
110
# File 'lib/generated_definitions/jp.rb', line 108

def self.jp_mountain_holiday(year)
  Date.civil(year, 8, 11)
end

.jp_national_culture_day(year) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/generated_definitions/jp.rb', line 77

def self.jp_national_culture_day(year)
  day =
    case year
    when 1851..1899
      22.2588
    when 1900..1979
      23.2588
    when 1980..2099
      23.2488
    when 2100..2150
      24.2488
    else
      raise IndexError.new("Out of range")
    end
  day += 0.242194 * (year - 1980) - ((year - 1980)/4).floor
  day = day.floor
  Date.civil(year, 9, day)
end

.jp_next_weekday(date) ⇒ Object



120
121
122
123
124
125
# File 'lib/generated_definitions/jp.rb', line 120

def self.jp_next_weekday(date)
  is_holiday = Holidays::JP.holidays_by_month[date.month].any? do |holiday|
    holiday[:mday] == date.day
  end
  date.wday == 0 || is_holiday ? Holidays.jp_next_weekday(date+1) : date
end

.jp_substitute_holiday(*date) ⇒ Object



113
114
115
116
117
# File 'lib/generated_definitions/jp.rb', line 113

def self.jp_substitute_holiday(*date)
  return nil unless date[0]
  date = date[0].kind_of?(Date) ? date.first : Date.civil(*date)
  date.wday == 0 ? Holidays.jp_next_weekday(date+1) : nil
end

.jp_vernal_equinox_day(year) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/generated_definitions/jp.rb', line 57

def self.jp_vernal_equinox_day(year)
  day =
    case year
    when 1851..1899
      19.8277
    when 1900..1979
      20.8357
    when 1980..2099
      20.8431
    when 2100..2150
      21.8510
    else
      raise IndexError.new("Out of range")
    end
  day += 0.242194 * (year - 1980) - ((year - 1980)/4).floor
  day = day.floor
  Date.civil(year, 3, day)
end

.load_allObject

Load all available holiday definitions



190
191
192
# File 'lib/holidays.rb', line 190

def load_all
  available(true).each { |path| require path }
end

.load_custom(*files) ⇒ Object

Parses provided holiday definition file(s) and loads them so that they are immediately available.



195
196
197
198
# File 'lib/holidays.rb', line 195

def load_custom(*files)
  regions, rules_by_month, custom_methods, tests = DefinitionFactory.file_parser.parse_definition_files(files)
  merge_defs(regions, rules_by_month)
end

.march_pub_hol_sa(year) ⇒ Object

www.safework.sa.gov.au/show_page.jsp?id=2483#.VQ9Mfmb8-8E The Holidays Act 1910 provides for the third Monday in May to be a public holiday. Since 2006 this public holiday has been observed on the second Monday in March through the issuing of a special Proclamation by the Governor.



105
106
107
108
109
110
111
# File 'lib/generated_definitions/au.rb', line 105

def self.march_pub_hol_sa(year)
  if year < 2006
    nil
  else
    Date.civil(year, 3, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 3, :second, :monday))
  end
end

.may_pub_hol_sa(year) ⇒ Object

www.safework.sa.gov.au/show_page.jsp?id=2483#.VQ9Mfmb8-8E The Holidays Act 1910 provides for the third Monday in May to be a public holiday. Since 2006 this public holiday has been observed on the second Monday in March through the issuing of a special Proclamation by the Governor.



116
117
118
119
120
121
122
# File 'lib/generated_definitions/au.rb', line 116

def self.may_pub_hol_sa(year)
  if year >= 2006
    nil
  else
    Date.civil(year, 5, Holidays::DateCalculatorFactory.day_of_month_calculator.call(year, 5, :third, :monday))
  end
end

.merge_defs(regions, holidays) ⇒ Object

TODO This should not be publicly available. I need to restructure the public

API for this class to something more sensible.


136
137
138
# File 'lib/holidays.rb', line 136

def merge_defs(regions, holidays) # :nodoc:
  DefinitionFactory.merger.call(regions, holidays)
end

.next_week(date) ⇒ Object



66
67
68
# File 'lib/generated_definitions/nz.rb', line 66

def self.next_week(date)
  date + 7
end

.on(date, *options) ⇒ Object

Get all holidays on a given date.

date

A Date object.

:options

One or more region symbols, :informal and/or :observed.

Returns an array of hashes or nil. See Holidays#between for the output format.

Also available via Date#holidays.



70
71
72
# File 'lib/holidays.rb', line 70

def on(date, *options)
  between(date, date, options)
end

.orthodox_easter(year) ⇒ Object



144
145
146
# File 'lib/holidays.rb', line 144

def orthodox_easter(year)
  DateCalculatorFactory::Easter::Gregorian.easter_calculator.calculate_orthodox_easter_for(year)
end

.orthodox_easter_julian(year) ⇒ Object



148
149
150
# File 'lib/holidays.rb', line 148

def orthodox_easter_julian(year)
  DateCalculatorFactory::Easter::Julian.easter_calculator.calculate_orthodox_easter_for(year)
end

.parse_definition_files_and_return_source(module_name, *files) ⇒ Object

Parses provided holiday definition file(s) and returns strings containing the generated module and test source



201
202
203
204
205
206
# File 'lib/holidays.rb', line 201

def parse_definition_files_and_return_source(module_name, *files)
  regions, rules_by_month, custom_methods, tests = DefinitionFactory.file_parser.parse_definition_files(files)
  module_src, test_src = DefinitionFactory.source_generator.generate_definition_source(module_name, files, regions, rules_by_month, custom_methods, tests)

  return module_src, test_src, regions
end

.ph_heroes_day(year) ⇒ Object

last Monday of August



42
43
44
45
46
# File 'lib/generated_definitions/ph.rb', line 42

def self.ph_heroes_day(year)
  date = Date.new(year, 8, -1)
  return date if date.wday == 1
  date -= date.wday - 1
end

.pl_trzech_kroli(year) ⇒ Object

Poland: January 6 is holiday since 2011



66
67
68
# File 'lib/generated_definitions/pl.rb', line 66

def self.pl_trzech_kroli(year)
  year >= 2011 ? 6 : nil
end

.pl_trzech_kroli_informal(year) ⇒ Object

Poland: January 6 wasn’t holiday before 2011



72
73
74
# File 'lib/generated_definitions/pl.rb', line 72

def self.pl_trzech_kroli_informal(year)
  year < 2011 ? 6 : nil
end

.previous_friday(date) ⇒ Object



61
62
63
# File 'lib/generated_definitions/nz.rb', line 61

def self.previous_friday(date)
  date - 3
end

.qld_labour_day_may(year) ⇒ Object



76
77
78
# File 'lib/generated_definitions/au.rb', line 76

def self.qld_labour_day_may(year)
  year <= 2012 ? Holidays.calculate_day_of_month(year, 5, 1, 1) : nil
end

.qld_labour_day_october(year) ⇒ Object



83
84
85
# File 'lib/generated_definitions/au.rb', line 83

def self.qld_labour_day_october(year)
  year <= 2012 ? nil : Holidays.calculate_day_of_month(year, 10, 1, 1)
end

.qld_queens_bday_october(year) ⇒ Object



69
70
71
# File 'lib/generated_definitions/au.rb', line 69

def self.qld_queens_bday_october(year)
  year == 2012 ? 1 : nil
end

.regionsObject

Returns an array of symbols of all the available holiday regions.



185
186
187
# File 'lib/holidays.rb', line 185

def regions
  DefinitionFactory.regions_repository.all
end

.se_alla_helgons_dag(year) ⇒ Object

Sweden: All Saint’s Day (Saturday between Oct 31 and Nov 6)



51
52
53
54
55
# File 'lib/generated_definitions/se.rb', line 51

def self.se_alla_helgons_dag(year)
  date = Date.civil(year,10,31)
  date += (6 - date.wday)
  date
end

.se_midsommardagen(year) ⇒ Object

Sweden: Mid-summer (Saturday between June 20–26)



43
44
45
46
47
# File 'lib/generated_definitions/se.rb', line 43

def self.se_midsommardagen(year)
  date = Date.civil(year,6,20)
  date += (6 - date.wday)
  date
end

.to_monday_if_sunday(date) ⇒ Object



152
153
154
# File 'lib/holidays.rb', line 152

def to_monday_if_sunday(date)
  DateCalculatorFactory.weekend_modifier.to_monday_if_sunday(date)
end

.to_monday_if_weekend(date) ⇒ Object



156
157
158
# File 'lib/holidays.rb', line 156

def to_monday_if_weekend(date)
  DateCalculatorFactory.weekend_modifier.to_monday_if_weekend(date)
end

.to_weekday_if_boxing_weekend(date) ⇒ Object



160
161
162
# File 'lib/holidays.rb', line 160

def to_weekday_if_boxing_weekend(date)
  DateCalculatorFactory.weekend_modifier.to_weekday_if_boxing_weekend(date)
end

.to_weekday_if_boxing_weekend_from_year(year) ⇒ Object



164
165
166
# File 'lib/holidays.rb', line 164

def to_weekday_if_boxing_weekend_from_year(year)
  DateCalculatorFactory.weekend_modifier.to_weekday_if_boxing_weekend_from_year(year)
end

.to_weekday_if_weekend(date) ⇒ Object



168
169
170
# File 'lib/holidays.rb', line 168

def to_weekday_if_weekend(date)
  DateCalculatorFactory.weekend_modifier.to_weekday_if_weekend(date)
end

.us_inauguration_day(year) ⇒ Object

January 20, every fourth year, following Presidential election



50
51
52
# File 'lib/generated_definitions/us.rb', line 50

def self.us_inauguration_day(year)
  year % 4 == 1 ? 20 : nil
end