Module Holidays
In: lib/holidays/ca.rb
lib/holidays/europe.rb
lib/holidays/es.rb
lib/holidays/br.rb
lib/holidays/no.rb
lib/holidays/fi.rb
lib/holidays/nyse.rb
lib/holidays/jp.rb
lib/holidays/nl.rb
lib/holidays/nz.rb
lib/holidays/pt.rb
lib/holidays/de.rb
lib/holidays/ups.rb
lib/holidays/cz.rb
lib/holidays/us.rb
lib/holidays/au.rb
lib/holidays/at.rb
lib/holidays/ie.rb
lib/holidays/is.rb
lib/holidays/za.rb
lib/holidays/mx.rb
lib/holidays/li.rb
lib/holidays/scandinavia.rb
lib/holidays/gb.rb
lib/holidays/pl.rb
lib/holidays/it.rb
lib/holidays/fr.rb
lib/holidays/dk.rb
lib/holidays/el.rb
lib/holidays/se.rb
lib/holidays/united_nations.rb
lib/holidays/north_america.rb
lib/holidays.rb

Region options

Holidays can be defined as belonging to one or more regions and sub regions. The Holidays#on, Holidays#between, Date#holidays and Date#holiday? methods each allow you to specify a specific region.

There are several different ways that you can specify a region:

:region
By region. For example, return holidays in the Canada with :ca.
:region_
By region and sub regions. For example, return holidays in Germany and all its sub regions with :de_.
:region_sub
By sub region. Return national holidays in Spain plus holidays in Spain‘s Valencia region with :es_v.
:any
Any region. Return holidays from any loaded region.

You can load all the available holiday definition sets by running

  Holidays.load_all

Other options

:observed
Return holidays on the day they are observed (e.g. on a Monday if they fall on a Sunday).
:informal
Include informal holidays (e.g. Valentine‘s Day)

Examples

Return all holidays in the :ca and :us regions on the day that they are observed.

  Holidays.between(from, to, :ca, :us, :observed)

Return all holidays in :ca and any :ca sub-region.

  Holidays.between(from, to, :ca_)

Return all holidays in :ca_bc sub-region (which includes the :ca), including informal holidays.

  Holidays.between(from, to, :ca_bc, :informal)

Methods

Classes and Modules

Class Holidays::UnknownRegionError

Constants

VERSION = '1.0.5'
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 }
DEFINITION_PATH = File.expand_path(File.dirname(__FILE__) + '/holidays/')

Public Class methods

Returns an array of symbols all the available holiday definitions.

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

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], ...}]

Monday on or before May 24

Monday on or before May 24

Germany: Wednesday before November 23

Germany: Wednesday before November 23

Get the date of Easter Sunday in a given year. From Easter Sunday, it is possible to calculate many traditional holidays in Western countries. Returns a Date object.

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

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

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

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

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.

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

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

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

Load all available holiday definitions

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.

A method to calculate the orthodox easter date, returns date in the Gregorian (western) calendar Safe until appr. 4100 AD, when one leap day will be removed. Returns a Date object.

Poland: January 6 is holiday since 2011

Poland: January 6 is holiday since 2011

Poland: January 6 wasn‘t holiday before 2011

Poland: January 6 wasn‘t holiday before 2011

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

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

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

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

Move date to Monday if it occurs on a Sunday. Used as a callback function.

Move date to Monday if it occurs on a Saturday on Sunday. Used as a callback function.

Move Boxing Day if it falls on a weekend, leaving room for Christmas. Used as a callback function.

Move date to Monday if it occurs on a Sunday or to Friday if it occurs on a Saturday. Used as a callback function.

January 20, every fourth year, following Presidential election

January 20, every fourth year, following Presidential election

[Validate]