This commit is contained in:
parent
24c09b7c08
commit
cf000b1df2
46 changed files with 554 additions and 876 deletions
8
README
8
README
|
@ -23,11 +23,11 @@ Extends Ruby's built-in Date class and supports custom holiday definition lists.
|
|||
|
||||
==== Extending Ruby's Date class
|
||||
# Lookup Canada Day in the :ca region
|
||||
Date.civil(2008,7,1).is_holiday?(:ca)
|
||||
Date.civil(2008,7,1).holiday?(:ca)
|
||||
=> true
|
||||
|
||||
# Lookup Canada Day in the :fr region
|
||||
Date.civil(2008,7,1).is_holiday?(:fr)
|
||||
Date.civil(2008,7,1).holiday?(:fr)
|
||||
=> false
|
||||
|
||||
=== Installation
|
||||
|
@ -39,10 +39,6 @@ To install the gem from RubyForge:
|
|||
Or, download the source <tt>.tgz</tt> file from http://rubyforge.org/holidays/ and
|
||||
extract it somewhere in your include path.
|
||||
|
||||
=== Custom holiday definitions
|
||||
|
||||
|
||||
|
||||
=== Credits and code
|
||||
|
||||
* Project page: http://code.dunae.ca/holidays
|
||||
|
|
|
@ -36,6 +36,7 @@ def parse_holiday_defs(module_name, files)
|
|||
end # /defs.each
|
||||
end
|
||||
end
|
||||
|
||||
if def_file['methods']
|
||||
puts " - importing methods..."
|
||||
def_file['methods'].each do |name, code|
|
||||
|
@ -89,11 +90,11 @@ module Holidays
|
|||
#
|
||||
# Definitions loaded: #{files.join(', ')}
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/#{module_name.downcase}'
|
||||
# require 'holidays/#{module_name.downcase}'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module #{module_name} # :nodoc:
|
||||
|
@ -102,13 +103,13 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
#{month_strs.join(",\n")}
|
||||
}
|
||||
end
|
||||
|
||||
#{method_str}
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::#{module_name}::DEFINED_REGIONS, Holidays::#{module_name}::HOLIDAYS_BY_MONTH)
|
||||
EOC
|
||||
EOC
|
||||
|
||||
|
||||
end
|
|
@ -6,16 +6,16 @@ months:
|
|||
0:
|
||||
- name: Good Friday
|
||||
regions: [au]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Easter Saturday
|
||||
regions: [au]
|
||||
function: lambda { |year| easter(year)-1 }
|
||||
function: lambda { |year| Holidays.easter(year)-1 }
|
||||
- name: Easter Monday
|
||||
regions: [au]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
- name: Easter Monday
|
||||
regions: [au_tas]
|
||||
function: lambda { |year| easter(year)+2 }
|
||||
function: lambda { |year| Holidays.easter(year)+2 }
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [au]
|
||||
|
|
|
@ -5,10 +5,10 @@ months:
|
|||
0:
|
||||
- name: Good Friday
|
||||
regions: [ca]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Easter Monday
|
||||
regions: [ca_qc]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [ca]
|
||||
|
@ -36,10 +36,10 @@ months:
|
|||
5:
|
||||
- name: Victoria Day
|
||||
regions: [ca]
|
||||
function: lambda { |year| ca_victoria_day(year) }
|
||||
function: lambda { |year| Holidays.ca_victoria_day(year) }
|
||||
- name: National Patriotes Day
|
||||
regions: [ca_qc]
|
||||
function: lambda { |year| ca_victoria_day(year) }
|
||||
function: lambda { |year| Holidays.ca_victoria_day(year) }
|
||||
6:
|
||||
- name: Discovery Day
|
||||
regions: [ca_nf]
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
0:
|
||||
- name: Easter Sunday
|
||||
regions: [christian]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: Palm Sunday
|
||||
regions: [christian]
|
||||
function: lambda { |year| easter(year)-7 }
|
||||
function: lambda { |year| Holidays.easter(year)-7 }
|
||||
- name: Good Friday
|
||||
regions: [christian]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
12:
|
||||
- name: Christmas Day
|
||||
regions: [christian]
|
||||
|
|
14
data/de.yaml
14
data/de.yaml
|
@ -8,24 +8,24 @@ months:
|
|||
0:
|
||||
- name: Karfreitag
|
||||
regions: [de]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Ostermontag
|
||||
regions: [de]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
- name: Christi Himmelfahrt
|
||||
regions: [de]
|
||||
function: lambda { |year| easter(year)+39 }
|
||||
function: lambda { |year| Holidays.easter(year)+39 }
|
||||
- name: Pfingstmontag
|
||||
regions: [de]
|
||||
function: lambda { |year| easter(year)+50 }
|
||||
function: lambda { |year| Holidays.easter(year)+50 }
|
||||
- name: Fronleichnam
|
||||
regions: [de_bw, de_by, de_he, de_nw, de_rp, de_sl, de_sn, de_th]
|
||||
function: lambda { |year| easter(year)+60 }
|
||||
function: lambda { |year| Holidays.easter(year)+60 }
|
||||
1:
|
||||
- name: Neujahrstag
|
||||
regions: [de]
|
||||
mday: 1
|
||||
- name: Heilige Drei Könige
|
||||
- name: Heilige Drei Könige
|
||||
regions: [de_bw, de_by]
|
||||
mday: 6
|
||||
5:
|
||||
|
@ -36,7 +36,7 @@ months:
|
|||
regions: [de]
|
||||
mday: 8
|
||||
8:
|
||||
- name: Mariä Himmelfahrt
|
||||
- name: Mariä Himmelfahrt
|
||||
regions: [de_by]
|
||||
mday: 15
|
||||
10:
|
||||
|
|
24
data/dk.yaml
24
data/dk.yaml
|
@ -10,38 +10,38 @@ months:
|
|||
0:
|
||||
- name: Fastelavn
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)-49 }
|
||||
function: lambda { |year| Holidays.easter(year)-49 }
|
||||
type: informal
|
||||
- name: Palmesøndag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)-7 }
|
||||
function: lambda { |year| Holidays.easter(year)-7 }
|
||||
- name: Skærtorsdag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)-3 }
|
||||
function: lambda { |year| Holidays.easter(year)-3 }
|
||||
- name: Langfredag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Påskedag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: 2. påskedag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
- name: Store Bededag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)+26 }
|
||||
function: lambda { |year| Holidays.easter(year)+26 }
|
||||
- name: Kristi Himmelfartsdag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)+40 }
|
||||
function: lambda { |year| Holidays.easter(year)+40 }
|
||||
- name: Kristi Himmelfartsdag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)+40 }
|
||||
function: lambda { |year| Holidays.easter(year)+40 }
|
||||
- name: 2. Pinsedag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)+49 }
|
||||
function: lambda { |year| Holidays.easter(year)+49 }
|
||||
- name: Pinsedag
|
||||
regions: [dk]
|
||||
function: lambda { |year| easter(year)+50 }
|
||||
function: lambda { |year| Holidays.easter(year)+50 }
|
||||
1:
|
||||
- name: Nytårsdag
|
||||
regions: [dk]
|
||||
|
@ -96,5 +96,5 @@ months:
|
|||
regions: [dk]
|
||||
mday: 25
|
||||
- name: 2. juledag
|
||||
regions: [dk_]
|
||||
regions: [dk]
|
||||
mday: 26
|
||||
|
|
|
@ -11,13 +11,13 @@ months:
|
|||
0:
|
||||
- name: Jueves Santo
|
||||
regions: [es_pv, es_ct, es_na, es_v, es_vc]
|
||||
function: lambda { |year| easter(year)-3 }
|
||||
function: lambda { |year| Holidays.easter(year)-3 }
|
||||
- name: Viernes Santo
|
||||
regions: [es]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Lunes de Pascua
|
||||
regions: [es_pv, es_ct, es_na, es_v, es_vc]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: Año Nuevo
|
||||
regions: [es]
|
||||
|
|
|
@ -8,16 +8,16 @@ months:
|
|||
0:
|
||||
- name: Pâques
|
||||
regions: [fr]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: Ascension
|
||||
regions: [fr]
|
||||
function: lambda { |year| easter(year)+40 }
|
||||
function: lambda { |year| Holidays.easter(year)+40 }
|
||||
- name: Pentecôte
|
||||
regions: [fr]
|
||||
function: lambda { |year| easter(year)+49 }
|
||||
function: lambda { |year| Holidays.easter(year)+49 }
|
||||
- name: Lundi de Pentecôte
|
||||
regions: [fr]
|
||||
function: lambda { |year| easter(year)+50 }
|
||||
function: lambda { |year| Holidays.easter(year)+50 }
|
||||
1:
|
||||
- name: Jour de l'an
|
||||
regions: [fr]
|
||||
|
|
|
@ -13,13 +13,13 @@ months:
|
|||
0:
|
||||
- name: Good Friday
|
||||
regions: [gb]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Easter Sunday
|
||||
regions: [gb]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: Easter Monday
|
||||
regions: [gb_eng, gb_wls, gb_eaw, gb_nir]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [gb]
|
||||
|
|
|
@ -7,7 +7,7 @@ months:
|
|||
0:
|
||||
- name: Easter Monday
|
||||
regions: [ie]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [ie]
|
||||
|
|
26
data/is.yaml
26
data/is.yaml
|
@ -10,43 +10,43 @@ months:
|
|||
0:
|
||||
- name: Bolludagur
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)-48 }
|
||||
function: lambda { |year| Holidays.easter(year)-48 }
|
||||
- name: Sprengidagur
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)-47 }
|
||||
function: lambda { |year| Holidays.easter(year)-47 }
|
||||
- name: Öskudagur
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)-46 }
|
||||
function: lambda { |year| Holidays.easter(year)-46 }
|
||||
- name: Pálmasunnudagur
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)-7 }
|
||||
function: lambda { |year| Holidays.easter(year)-7 }
|
||||
- name: Skírdagur
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)-3 }
|
||||
function: lambda { |year| Holidays.easter(year)-3 }
|
||||
- name: Föstudaginn langi
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Páskadagur
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: Annar í páskum
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
- name: Store Bededag
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)+26 }
|
||||
function: lambda { |year| Holidays.easter(year)+26 }
|
||||
- name: Kristi Himmelfartsdag
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)+40 }
|
||||
function: lambda { |year| Holidays.easter(year)+40 }
|
||||
- name: Kristi Himmelfartsdag
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)+40 }
|
||||
function: lambda { |year| Holidays.easter(year)+40 }
|
||||
- name: 2. Pinsedag
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)+49 }
|
||||
function: lambda { |year| Holidays.easter(year)+49 }
|
||||
- name: Pinsedag
|
||||
regions: [is]
|
||||
function: lambda { |year| easter(year)+50 }
|
||||
function: lambda { |year| Holidays.easter(year)+50 }
|
||||
1:
|
||||
- name: Nýársdagur
|
||||
regions: [is]
|
||||
|
|
|
@ -8,10 +8,10 @@ months:
|
|||
0:
|
||||
- name: Pasqua
|
||||
regions: [it]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: Lunedì dell'Angelo
|
||||
regions: [it]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: Capodanno
|
||||
regions: [it]
|
||||
|
|
|
@ -8,13 +8,13 @@ months:
|
|||
0:
|
||||
- name: Liela Piektdiena
|
||||
regions: [lv]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Lieldienas
|
||||
regions: [lv]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: 2. Lieldienas
|
||||
regions: [lv]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: Jaunais Gads
|
||||
regions: [lv]
|
||||
|
|
|
@ -5,13 +5,13 @@ months:
|
|||
0:
|
||||
- name: Good Thursday
|
||||
regions: [mx]
|
||||
function: lambda { |year| easter(year)-3 }
|
||||
function: lambda { |year| Holidays.easter(year)-3 }
|
||||
- name: Good Friday
|
||||
regions: [mx]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Easter Sunday
|
||||
regions: [mx]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [mx]
|
||||
|
|
12
data/nl.yaml
12
data/nl.yaml
|
@ -9,22 +9,22 @@ months:
|
|||
0:
|
||||
- name: Goede Vrijdag
|
||||
regions: [nl]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Pasen
|
||||
regions: [nl]
|
||||
function: lambda { |year| easter(year) }
|
||||
function: lambda { |year| Holidays.easter(year) }
|
||||
- name: Pasen
|
||||
regions: [nl]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
- name: Hemelvaartsdag
|
||||
regions: [nl]
|
||||
function: lambda { |year| easter(year)+39 }
|
||||
function: lambda { |year| Holidays.easter(year)+39 }
|
||||
- name: Pinksteren
|
||||
regions: [nl]
|
||||
function: lambda { |year| easter(year)+49 }
|
||||
function: lambda { |year| Holidays.easter(year)+49 }
|
||||
- name: Pinksteren
|
||||
regions: [nl]
|
||||
function: lambda { |year| easter(year)+50 }
|
||||
function: lambda { |year| Holidays.easter(year)+50 }
|
||||
1:
|
||||
- name: Nieuwjaar
|
||||
regions: [nl]
|
||||
|
|
|
@ -5,7 +5,7 @@ months:
|
|||
0:
|
||||
- name: Good Friday
|
||||
regions: [us]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
type: informal
|
||||
2:
|
||||
- name: Groundhog Day
|
||||
|
|
|
@ -13,7 +13,7 @@ months:
|
|||
regions: [us]
|
||||
wday: 1
|
||||
- name: Inauguration Day
|
||||
function: lambda { |year| us_inauguration_day(year) }
|
||||
function: lambda { |year| Holidays.us_inauguration_day(year) }
|
||||
regions: [us]
|
||||
3:
|
||||
- name: Presidents' Day
|
||||
|
|
|
@ -9,10 +9,10 @@ months:
|
|||
0:
|
||||
- name: Good Friday
|
||||
regions: [za]
|
||||
function: lambda { |year| easter(year)-2 }
|
||||
function: lambda { |year| Holidays.easter(year)-2 }
|
||||
- name: Family Day
|
||||
regions: [za]
|
||||
function: lambda { |year| easter(year)+1 }
|
||||
function: lambda { |year| Holidays.easter(year)+1 }
|
||||
1:
|
||||
- name: New Year's Day
|
||||
regions: [za]
|
||||
|
|
|
@ -1,7 +1,38 @@
|
|||
$:.unshift File.dirname(__FILE__)
|
||||
|
||||
require 'digest/md5'
|
||||
|
||||
# == Ruby Holidays module
|
||||
#
|
||||
# === Using regions
|
||||
# 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.
|
||||
#
|
||||
# ==== Regions
|
||||
# To select all holidays during May in the CA region (Canada), you might call:
|
||||
# Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
||||
#
|
||||
# Which would return Victoria Day, a national holiday in Canada.
|
||||
# => [{:name => 'Victoria Day',...}...]
|
||||
#
|
||||
# ==== Sub regions
|
||||
# In the Canadian Province of Québec, there's another holiday in May.
|
||||
# Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_pq)
|
||||
#
|
||||
# This query would return all holidays in both the parent region (<tt>:ca</tt>) and the
|
||||
# sub region (<tt>:ca_pq</tt>).
|
||||
# => [{:name => 'Victoria Day',...}, {:name => 'Journée nationale des Patriotes',...}...]
|
||||
#
|
||||
# ==== Wildcard sub regions
|
||||
# To avoid having to return enter a long list of regions, you can append an underscore
|
||||
# to the end of the region symbol. This selects an entire region, including its sub-regions.
|
||||
# Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_)
|
||||
# => [{:name => 'Victoria Day',...}, {:name => 'Journée nationale des Patriotes',...}...]
|
||||
#
|
||||
# ==== All regions
|
||||
# Finally, you can select holidays that occur in any region using <tt>:any</tt>.
|
||||
#
|
||||
#
|
||||
module Holidays
|
||||
# Exception thrown when an unknown region is requested.
|
||||
class UnkownRegionError < ArgumentError; end
|
||||
|
@ -38,9 +69,7 @@ module Holidays
|
|||
# Returns an array of hashes or nil.
|
||||
#
|
||||
# Each holiday is returned as a hash with the following fields:
|
||||
# [<tt>:year</tt>] Integer.
|
||||
# [<tt>:month</tt>] Integer.
|
||||
# [<tt>:day</tt>] Integer.
|
||||
# [<tt>:date</tt>] Ruby Date object.
|
||||
# [<tt>:name</tt>] String.
|
||||
# [<tt>:regions</tt>] An array of region symbols.
|
||||
#--
|
||||
|
@ -64,7 +93,6 @@ module Holidays
|
|||
next unless in_region?(regions, h[:regions])
|
||||
|
||||
if h[:function]
|
||||
#result = h[:function].call(year)
|
||||
result = call_proc(h[:function], year)
|
||||
if result.kind_of?(Date)
|
||||
month = result.month
|
||||
|
@ -76,8 +104,9 @@ module Holidays
|
|||
mday = h[:mday] || Date.calculate_mday(year, month, h[:week], h[:wday])
|
||||
end
|
||||
|
||||
if Date.new(year, month, mday).between?(start_date, end_date)
|
||||
holidays << {:month => month, :day => mday, :year => year, :name => h[:name], :regions => h[:regions]}
|
||||
date = Date.new(year, month, mday)
|
||||
if date.between?(start_date, end_date)
|
||||
holidays << {:date => date, :name => h[:name], :regions => h[:regions]}
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -91,7 +120,7 @@ module Holidays
|
|||
#
|
||||
# This method is automatically called when including holiday definition
|
||||
# files.
|
||||
def self.merge_defs(regions, holidays)
|
||||
def self.merge_defs(regions, holidays) # :nodoc:
|
||||
@@regions = @@regions | regions
|
||||
@@regions.uniq!
|
||||
|
||||
|
@ -103,13 +132,56 @@ module Holidays
|
|||
end
|
||||
end
|
||||
|
||||
# Get the date of Easter Sunday in a given year. From Easter Sunday, it is
|
||||
# possible to calculate many traditional holidays in Western countries.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
# Check regions against list of supported regions and return an array of
|
||||
# symbols.
|
||||
#
|
||||
# If a wildcard region is found (e.g. <tt>:ca_</tt>) it is expanded into all
|
||||
# of its available sub regions.
|
||||
def self.validate_regions(regions) # :nodoc:
|
||||
regions = [regions] unless regions.kind_of?(Array)
|
||||
regions = regions.collect { |r| r.to_sym }
|
||||
|
||||
# Found sub region wild-card
|
||||
regions.delete_if do |reg|
|
||||
if reg.to_s =~ /_$/
|
||||
regions << @@regions.select { |dr| dr.to_s =~ Regexp.new("^#{reg}") }
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
regions.flatten!
|
||||
|
||||
raise UnkownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) }
|
||||
|
||||
regions
|
||||
|
@ -119,7 +191,7 @@ private
|
|||
#
|
||||
# When request :any, all holidays should be returned.
|
||||
# When requesting :ca_bc, holidays in :ca or :ca_bc should be returned.
|
||||
# When requesting :ca, only holidays in :ca should be returned.
|
||||
# When requesting :ca, holidays in :ca but not its subregions should be returned.
|
||||
def self.in_region?(requested, available) # :nodoc:
|
||||
return true if requested.include?(:any)
|
||||
|
||||
|
@ -131,11 +203,9 @@ private
|
|||
|
||||
requested = requested.flatten.uniq
|
||||
|
||||
available.any? { |r| requested.include?(r) }
|
||||
available.any? { |avail| requested.include?(avail) }
|
||||
end
|
||||
|
||||
|
||||
|
||||
# Call a proc function defined in a holiday definition file.
|
||||
#
|
||||
# Procs are cached.
|
||||
|
@ -164,8 +234,6 @@ private
|
|||
@@proc_cache[proc_key] = function.call(year) unless @@proc_cache[proc_key]
|
||||
@@proc_cache[proc_key]
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -240,7 +308,4 @@ class Date
|
|||
|
||||
return days - ((Date.civil(year, month, days).wday - wday + 7) % 7)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -17,6 +17,7 @@ installation:
|
|||
* holidays/mx
|
||||
* holidays/nl
|
||||
* holidays/north_america
|
||||
* holidays/scandinavia
|
||||
* holidays/united_nations
|
||||
* holidays/us
|
||||
* holidays/za
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/au.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/au.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/au'
|
||||
# require 'holidays/au'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module AU # :nodoc:
|
||||
|
@ -15,10 +15,10 @@ module Holidays
|
|||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld, :au_nt]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:au]},
|
||||
{:function => lambda { |year| easter(year)-1 }, :name => "Easter Saturday", :regions => [:au]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Easter Monday", :regions => [:au]},
|
||||
{:function => lambda { |year| easter(year)+2 }, :name => "Easter Monday", :regions => [:au_tas]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:au]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-1 }, :name => "Easter Saturday", :regions => [:au]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Easter Monday", :regions => [:au]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+2 }, :name => "Easter Monday", :regions => [:au_tas]}],
|
||||
6 => [{:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au]},
|
||||
{:mday => 6, :type => :informal, :name => "Queensland Day", :regions => [:au_qld]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:au]},
|
||||
|
@ -30,34 +30,7 @@ module Holidays
|
|||
4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]}],
|
||||
10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Monday on or before May 24
|
||||
def self.ca_victoria_day(year)
|
||||
|
@ -71,7 +44,6 @@ def self.ca_victoria_day(year)
|
|||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::AU::DEFINED_REGIONS, Holidays::AU::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/ca.yaml, data/common_methods.yaml, data/north_america_informal.yaml
|
||||
# Definitions loaded: data/ca.yaml, data/north_america_informal.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/ca'
|
||||
# require 'holidays/ca'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module CA # :nodoc:
|
||||
DEFINED_REGIONS = [:ca, :ca_qc, :us, :ca_nf, :ca_nt, :ca_nu, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_bc, :ca_ns, :ca_yk]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:function => lambda { |year| ca_victoria_day(year) }, :name => "Victoria Day", :regions => [:ca]},
|
||||
{:function => lambda { |year| ca_victoria_day(year) }, :name => "National Patriotes Day", :regions => [:ca_qc]},
|
||||
5 => [{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :name => "Victoria Day", :regions => [:ca]},
|
||||
{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :name => "National Patriotes Day", :regions => [:ca_qc]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:ca, :us]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Easter Monday", :regions => [:ca_qc]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:ca, :us]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Easter Monday", :regions => [:ca_qc]}],
|
||||
11 => [{:mday => 11, :name => "Rememberance Day", :regions => [:ca]}],
|
||||
6 => [{:mday => 24, :name => "Discovery Day", :regions => [:ca_nf]},
|
||||
{:mday => 24, :name => "Fête Nationale", :regions => [:ca_qc]},
|
||||
|
@ -48,34 +48,7 @@ module Holidays
|
|||
10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
|
||||
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Monday on or before May 24
|
||||
def self.ca_victoria_day(year)
|
||||
|
@ -89,7 +62,6 @@ def self.ca_victoria_day(year)
|
|||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::CA::DEFINED_REGIONS, Holidays::CA::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/de.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/de.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/de'
|
||||
# require 'holidays/de'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module DE # :nodoc:
|
||||
|
@ -16,11 +16,11 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Tag der Arbeit", :regions => [:de]},
|
||||
{:mday => 8, :name => "Victoire 1945", :regions => [:de]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Karfreitag", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Ostermontag", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+39 }, :name => "Christi Himmelfahrt", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pfingstmontag", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+60 }, :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Karfreitag", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Ostermontag", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+39 }, :name => "Christi Himmelfahrt", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pfingstmontag", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+60 }, :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th]}],
|
||||
11 => [{:mday => 1, :name => "Allerheiligen", :regions => [:de_bw, :de_by, :de_nw, :de_rp, :de_sl]}],
|
||||
1 => [{:mday => 1, :name => "Neujahrstag", :regions => [:de]},
|
||||
{:mday => 6, :name => "Heilige Drei Könige", :regions => [:de_bw, :de_by]}],
|
||||
|
@ -30,37 +30,9 @@ module Holidays
|
|||
10 => [{:mday => 3, :name => "Tag der Deutschen Einheit", :regions => [:de]},
|
||||
{:mday => 31, :name => "Reformationstag", :regions => [:de_bb, :de_mv, :de_sn, :de_st, :de_th]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::DE::DEFINED_REGIONS, Holidays::DE::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/dk.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/dk.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/dk'
|
||||
# require 'holidays/dk'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module DK # :nodoc:
|
||||
DEFINED_REGIONS = [:dk, :dk_]
|
||||
DEFINED_REGIONS = [:dk]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
||||
{:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-49 }, :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)-7 }, :name => "Palmesøndag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)-3 }, :name => "Skærtorsdag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Langfredag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "2. påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)+26 }, :name => "Store Bededag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:dk, :dk]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "2. Pinsedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pinsedag", :regions => [:dk]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :name => "Palmesøndag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Skærtorsdag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Langfredag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "2. påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+26 }, :name => "Store Bededag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:dk, :dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "2. Pinsedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pinsedag", :regions => [:dk]}],
|
||||
11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]}],
|
||||
6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]},
|
||||
{:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]},
|
||||
|
@ -34,42 +34,14 @@ module Holidays
|
|||
12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]},
|
||||
{:mday => 24, :name => "Juleaftensdag", :regions => [:dk]},
|
||||
{:mday => 25, :name => "1. juledag", :regions => [:dk]},
|
||||
{:mday => 26, :name => "2. juledag", :regions => [:dk_]}],
|
||||
{:mday => 26, :name => "2. juledag", :regions => [:dk]}],
|
||||
4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]},
|
||||
{:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]},
|
||||
{:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::DK::DEFINED_REGIONS, Holidays::DK::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/es.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/es.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/es'
|
||||
# require 'holidays/es'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module ES # :nodoc:
|
||||
|
@ -18,9 +18,9 @@ module Holidays
|
|||
{:mday => 2, :name => "Fiesta de la Comunidad", :regions => [:es_m]},
|
||||
{:mday => 30, :name => "Día de las Canarias", :regions => [:es_cn]},
|
||||
{:mday => 31, :name => "Día de la Región Castilla-La Mancha", :regions => [:es_cm]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-3 }, :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Viernes Santo", :regions => [:es]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Lunes de Pascua", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Viernes Santo", :regions => [:es]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Lunes de Pascua", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}],
|
||||
11 => [{:mday => 1, :name => "Todos los Santos", :regions => [:es]}],
|
||||
6 => [{:mday => 9, :name => "Día de la Región de Murcia", :regions => [:es_mu]},
|
||||
{:mday => 9, :name => "Día de La Rioja", :regions => [:es_lo]}],
|
||||
|
@ -44,37 +44,9 @@ module Holidays
|
|||
10 => [{:mday => 9, :name => "Día de Valencia", :regions => [:es_vc, :es_v]},
|
||||
{:mday => 12, :name => "Día de la Hispanidad", :regions => [:es]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::ES::DEFINED_REGIONS, Holidays::ES::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/dk.yaml, data/common_methods.yaml, data/de.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/nl.yaml, data/lv.yaml
|
||||
# Definitions loaded: data/dk.yaml, data/de.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/nl.yaml, data/lv.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/europe'
|
||||
# require 'holidays/europe'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module EUROPE # :nodoc:
|
||||
DEFINED_REGIONS = [:dk, :is, :dk_, :de, :fr, :de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_he, :de_sn, :de_th, :de_bb, :de_mv, :de_st, :es, :es_m, :es_cn, :es_cm, :es_pv, :es_ct, :es_na, :es_v, :es_vc, :es_mu, :es_lo, :es_ib, :es_ga, :es_an, :es_ce, :es_o, :es_ex, :es_ar, :es_cl, :gb, :ie, :je, :gb_jsy, :gg, :gb_gsy, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :im, :gb_iom, :gb_con, :it, :nl, :lv]
|
||||
DEFINED_REGIONS = [:dk, :is, :de, :fr, :de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_he, :de_sn, :de_th, :de_bb, :de_mv, :de_st, :es, :es_m, :es_cn, :es_cm, :es_pv, :es_ct, :es_na, :es_v, :es_vc, :es_mu, :es_lo, :es_ib, :es_ga, :es_an, :es_ce, :es_o, :es_ex, :es_ar, :es_cl, :gb, :ie, :je, :gb_jsy, :gg, :gb_gsy, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :im, :gb_iom, :gb_con, :it, :nl, :lv]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
||||
|
@ -33,50 +33,50 @@ module Holidays
|
|||
{:mday => 5, :name => "Bevrijdingsdag", :regions => [:nl]},
|
||||
{:mday => 1, :name => "Darba svetki", :regions => [:lv]},
|
||||
{:mday => 4, :name => "Neatkaribas deklaracijas pasludinašanas diena", :regions => [:lv]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-49 }, :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)-7 }, :name => "Palmesøndag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)-3 }, :name => "Skærtorsdag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Langfredag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "2. påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| easter(year)+26 }, :name => "Store Bededag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:dk, :dk, :is]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "2. Pinsedag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pinsedag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Karfreitag", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Ostermontag", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+39 }, :name => "Christi Himmelfahrt", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pfingstmontag", :regions => [:de]},
|
||||
{:function => lambda { |year| easter(year)+60 }, :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th]},
|
||||
{:function => lambda { |year| easter(year)-3 }, :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Viernes Santo", :regions => [:es]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Lunes de Pascua", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Pâques", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)+40 }, :name => "Ascension", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "Pentecôte", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Lundi de Pentecôte", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:gb]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Easter Sunday", :regions => [:gb]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie]},
|
||||
{:function => lambda { |year| easter(year)-48 }, :name => "Bolludagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-47 }, :name => "Sprengidagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-46 }, :name => "Öskudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-7 }, :name => "Pálmasunnudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-3 }, :name => "Skírdagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Föstudaginn langi", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Páskadagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Annar í páskum", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Pasqua", :regions => [:it]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Lunedì dell'Angelo", :regions => [:it]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Goede Vrijdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+39 }, :name => "Hemelvaartsdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "Pinksteren", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pinksteren", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Liela Piektdiena", :regions => [:lv]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Lieldienas", :regions => [:lv]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "2. Lieldienas", :regions => [:lv]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :name => "Palmesøndag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Skærtorsdag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Langfredag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "2. påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+26 }, :name => "Store Bededag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:dk, :dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "2. Pinsedag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pinsedag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Karfreitag", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Ostermontag", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+39 }, :name => "Christi Himmelfahrt", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pfingstmontag", :regions => [:de]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+60 }, :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Viernes Santo", :regions => [:es]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Lunes de Pascua", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Pâques", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+40 }, :name => "Ascension", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "Pentecôte", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Lundi de Pentecôte", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:gb]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Easter Sunday", :regions => [:gb]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-48 }, :name => "Bolludagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-47 }, :name => "Sprengidagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-46 }, :name => "Öskudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :name => "Pálmasunnudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Skírdagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Föstudaginn langi", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Páskadagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Annar í páskum", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Pasqua", :regions => [:it]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Lunedì dell'Angelo", :regions => [:it]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Goede Vrijdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+39 }, :name => "Hemelvaartsdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "Pinksteren", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pinksteren", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Liela Piektdiena", :regions => [:lv]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Lieldienas", :regions => [:lv]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "2. Lieldienas", :regions => [:lv]}],
|
||||
11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]},
|
||||
{:mday => 1, :name => "Allerheiligen", :regions => [:de_bw, :de_by, :de_nw, :de_rp, :de_sl]},
|
||||
{:mday => 1, :name => "Todos los Santos", :regions => [:es]},
|
||||
|
@ -112,7 +112,7 @@ module Holidays
|
|||
12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]},
|
||||
{:mday => 24, :name => "Juleaftensdag", :regions => [:dk]},
|
||||
{:mday => 25, :name => "1. juledag", :regions => [:dk]},
|
||||
{:mday => 26, :name => "2. juledag", :regions => [:dk_]},
|
||||
{:mday => 26, :name => "2. juledag", :regions => [:dk]},
|
||||
{:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]},
|
||||
{:mday => 25, :name => "2. Weihnachtstag", :regions => [:de]},
|
||||
{:mday => 6, :name => "Día de la Constitución", :regions => [:es]},
|
||||
|
@ -171,6 +171,7 @@ module Holidays
|
|||
{:mday => 12, :name => "Día de la Hispanidad", :regions => [:es]},
|
||||
{:wday => 1, :week => -1, :name => "October Holiday", :regions => [:ie]}]
|
||||
}
|
||||
end
|
||||
|
||||
# Iceland: first day of summer (Thursday after 18 April)
|
||||
def self.is_sumardagurinn_fyrsti(year)
|
||||
|
@ -183,36 +184,7 @@ def self.is_sumardagurinn_fyrsti(year)
|
|||
date
|
||||
end
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::EUROPE::DEFINED_REGIONS, Holidays::EUROPE::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/fr.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/fr.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/fr'
|
||||
# require 'holidays/fr'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module FR # :nodoc:
|
||||
|
@ -16,10 +16,10 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Fête du travail", :regions => [:fr]},
|
||||
{:mday => 8, :name => "Victoire 1945", :regions => [:fr]}],
|
||||
0 => [{:function => lambda { |year| easter(year) }, :name => "Pâques", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)+40 }, :name => "Ascension", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "Pentecôte", :regions => [:fr]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Lundi de Pentecôte", :regions => [:fr]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year) }, :name => "Pâques", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+40 }, :name => "Ascension", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "Pentecôte", :regions => [:fr]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Lundi de Pentecôte", :regions => [:fr]}],
|
||||
11 => [{:mday => 1, :name => "Toussaint", :regions => [:fr]},
|
||||
{:mday => 11, :name => "Armistice 1918", :regions => [:fr]}],
|
||||
1 => [{:mday => 1, :name => "Jour de l'an", :regions => [:fr]}],
|
||||
|
@ -27,37 +27,9 @@ module Holidays
|
|||
7 => [{:mday => 14, :name => "Fête nationale", :regions => [:fr]}],
|
||||
8 => [{:mday => 15, :name => "Assomption", :regions => [:fr]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::FR::DEFINED_REGIONS, Holidays::FR::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/gb.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/gb.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/gb'
|
||||
# require 'holidays/gb'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module GB # :nodoc:
|
||||
|
@ -17,9 +17,9 @@ module Holidays
|
|||
5 => [{:wday => 1, :week => 1, :name => "May Day", :regions => [:gb]},
|
||||
{:mday => 9, :name => "Liberation Day", :regions => [:je, :gb_jsy, :gg, :gb_gsy]},
|
||||
{:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:gb]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Easter Sunday", :regions => [:gb]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:gb]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Easter Sunday", :regions => [:gb]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:gb]},
|
||||
{:mday => 2, :name => "New Year's", :regions => [:gb_sct]}],
|
||||
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:gb]},
|
||||
|
@ -31,37 +31,9 @@ module Holidays
|
|||
3 => [{:mday => 5, :name => "St. Piran's Day", :regions => [:gb_con]},
|
||||
{:mday => 17, :name => "St. Patrick's Day", :regions => [:gb_nir]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::GB::DEFINED_REGIONS, Holidays::GB::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/ie.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/ie.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/ie'
|
||||
# require 'holidays/ie'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module IE # :nodoc:
|
||||
|
@ -15,7 +15,7 @@ module Holidays
|
|||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:wday => 1, :week => 1, :name => "May Day", :regions => [:ie]}],
|
||||
0 => [{:function => lambda { |year| easter(year)+1 }, :name => "Easter Monday", :regions => [:ie]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Easter Monday", :regions => [:ie]}],
|
||||
6 => [{:wday => 1, :week => 1, :name => "Labour Day/May Day", :regions => [:ie]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ie]}],
|
||||
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ie]},
|
||||
|
@ -24,37 +24,9 @@ module Holidays
|
|||
3 => [{:mday => 17, :name => "St. Patrick's Day", :regions => [:ie]}],
|
||||
10 => [{:wday => 1, :week => -1, :name => "October Holiday", :regions => [:ie]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::IE::DEFINED_REGIONS, Holidays::IE::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/is.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/is.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/is'
|
||||
# require 'holidays/is'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module IS # :nodoc:
|
||||
|
@ -16,18 +16,18 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]},
|
||||
{:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-48 }, :name => "Bolludagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-47 }, :name => "Sprengidagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-46 }, :name => "Öskudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-7 }, :name => "Pálmasunnudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-3 }, :name => "Skírdagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Föstudaginn langi", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Páskadagur", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Annar í páskum", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)+26 }, :name => "Store Bededag", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:is, :is]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "2. Pinsedag", :regions => [:is]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pinsedag", :regions => [:is]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-48 }, :name => "Bolludagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-47 }, :name => "Sprengidagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-46 }, :name => "Öskudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :name => "Pálmasunnudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Skírdagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Föstudaginn langi", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Páskadagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Annar í páskum", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+26 }, :name => "Store Bededag", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:is, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "2. Pinsedag", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pinsedag", :regions => [:is]}],
|
||||
11 => [{:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}],
|
||||
1 => [{:mday => 1, :name => "Nýársdagur", :regions => [:is]},
|
||||
{:mday => 6, :name => "Þrettándinn", :regions => [:is]},
|
||||
|
@ -39,6 +39,7 @@ module Holidays
|
|||
2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}],
|
||||
8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}]
|
||||
}
|
||||
end
|
||||
|
||||
# Iceland: first day of summer (Thursday after 18 April)
|
||||
def self.is_sumardagurinn_fyrsti(year)
|
||||
|
@ -51,36 +52,7 @@ def self.is_sumardagurinn_fyrsti(year)
|
|||
date
|
||||
end
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::IS::DEFINED_REGIONS, Holidays::IS::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,63 +1,35 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/it.yaml, data/common_methods.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/it'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module IT # :nodoc:
|
||||
DEFINED_REGIONS = [:it]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]}],
|
||||
0 => [{:function => lambda { |year| easter(year) }, :name => "Pasqua", :regions => [:it]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Lunedì dell'Angelo", :regions => [:it]}],
|
||||
11 => [{:mday => 1, :name => "Ognissanti", :regions => [:it]}],
|
||||
6 => [{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]}],
|
||||
1 => [{:mday => 1, :name => "Capodanno", :regions => [:it]},
|
||||
{:mday => 6, :name => "Epifania", :regions => [:it]}],
|
||||
12 => [{:mday => 8, :name => "Immacolata Concezione", :regions => [:it]},
|
||||
{:mday => 25, :name => "Natale", :regions => [:it]},
|
||||
{:mday => 26, :name => "Santo Stefano", :regions => [:it]}],
|
||||
8 => [{:mday => 15, :name => "Assunzione", :regions => [:it]}],
|
||||
4 => [{:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::IT::DEFINED_REGIONS, Holidays::IT::HOLIDAYS_BY_MONTH)
|
||||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/it.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'holidays/it'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module IT # :nodoc:
|
||||
DEFINED_REGIONS = [:it]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year) }, :name => "Pasqua", :regions => [:it]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Lunedì dell'Angelo", :regions => [:it]}],
|
||||
11 => [{:mday => 1, :name => "Ognissanti", :regions => [:it]}],
|
||||
6 => [{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]}],
|
||||
1 => [{:mday => 1, :name => "Capodanno", :regions => [:it]},
|
||||
{:mday => 6, :name => "Epifania", :regions => [:it]}],
|
||||
12 => [{:mday => 8, :name => "Immacolata Concezione", :regions => [:it]},
|
||||
{:mday => 25, :name => "Natale", :regions => [:it]},
|
||||
{:mday => 26, :name => "Santo Stefano", :regions => [:it]}],
|
||||
8 => [{:mday => 15, :name => "Assunzione", :regions => [:it]}],
|
||||
4 => [{:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}]
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::IT::DEFINED_REGIONS, Holidays::IT::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/lv.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/lv.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/lv'
|
||||
# require 'holidays/lv'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module LV # :nodoc:
|
||||
|
@ -16,9 +16,9 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Darba svetki", :regions => [:lv]},
|
||||
{:mday => 4, :name => "Neatkaribas deklaracijas pasludinašanas diena", :regions => [:lv]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Liela Piektdiena", :regions => [:lv]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Lieldienas", :regions => [:lv]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "2. Lieldienas", :regions => [:lv]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Liela Piektdiena", :regions => [:lv]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Lieldienas", :regions => [:lv]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "2. Lieldienas", :regions => [:lv]}],
|
||||
11 => [{:mday => 18, :name => "Latvijas Republikas proklamešanas diena", :regions => [:lv]}],
|
||||
6 => [{:mday => 23, :name => "Ligo Diena", :regions => [:lv]},
|
||||
{:mday => 24, :name => "Jani", :regions => [:lv]}],
|
||||
|
@ -27,37 +27,9 @@ module Holidays
|
|||
{:mday => 25, :name => "2. Ziemassvetki", :regions => [:lv]},
|
||||
{:mday => 31, :name => "Vecgada vakars", :regions => [:lv]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::LV::DEFINED_REGIONS, Holidays::LV::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/mx.yaml, data/common_methods.yaml, data/north_america_informal.yaml
|
||||
# Definitions loaded: data/mx.yaml, data/north_america_informal.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/mx'
|
||||
# require 'holidays/mx'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module MX # :nodoc:
|
||||
|
@ -17,9 +17,9 @@ module Holidays
|
|||
5 => [{:mday => 1, :name => "D\xC3\xADa del Trabajo", :regions => [:mx]},
|
||||
{:mday => 5, :name => "La Batalla de Puebla", :regions => [:mx]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-3 }, :name => "Good Thursday", :regions => [:mx]},
|
||||
{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:mx, :us]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Easter Sunday", :regions => [:mx]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Good Thursday", :regions => [:mx]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:mx, :us]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Easter Sunday", :regions => [:mx]}],
|
||||
11 => [{:mday => 2, :name => "Dia de Muertos", :regions => [:mx]},
|
||||
{:wday => 1, :week => 3, :name => "D\xC3\xADa de la Revoluci\xC3\xB3n", :regions => [:mx]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:mx]},
|
||||
|
@ -36,37 +36,9 @@ module Holidays
|
|||
{:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}],
|
||||
10 => [{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::MX::DEFINED_REGIONS, Holidays::MX::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/nl.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/nl.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/nl'
|
||||
# require 'holidays/nl'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module NL # :nodoc:
|
||||
|
@ -16,49 +16,21 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 4, :name => "Dodenherdenking", :regions => [:nl]},
|
||||
{:mday => 5, :name => "Bevrijdingsdag", :regions => [:nl]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Goede Vrijdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+39 }, :name => "Hemelvaartsdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+49 }, :name => "Pinksteren", :regions => [:nl]},
|
||||
{:function => lambda { |year| easter(year)+50 }, :name => "Pinksteren", :regions => [:nl]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Goede Vrijdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Pasen", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+39 }, :name => "Hemelvaartsdag", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "Pinksteren", :regions => [:nl]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pinksteren", :regions => [:nl]}],
|
||||
1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]}],
|
||||
12 => [{:mday => 5, :type => :informal, :name => "Sinterklaas", :regions => [:nl]},
|
||||
{:mday => 25, :name => "Kerstmis", :regions => [:nl]},
|
||||
{:mday => 26, :name => "Kerstmis", :regions => [:nl]}],
|
||||
4 => [{:mday => 30, :name => "Koninginnedag", :regions => [:nl]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::NL::DEFINED_REGIONS, Holidays::NL::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/ca.yaml, data/common_methods.yaml, data/north_america_informal.yaml, data/mx.yaml, data/us.yaml
|
||||
# Definitions loaded: data/ca.yaml, data/north_america_informal.yaml, data/mx.yaml, data/us.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/north_america'
|
||||
# require 'holidays/north_america'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module NORTH_AMERICA # :nodoc:
|
||||
DEFINED_REGIONS = [:ca, :ca_qc, :us, :mx, :ca_nf, :ca_nt, :ca_nu, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_bc, :ca_ns, :ca_yk]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:function => lambda { |year| ca_victoria_day(year) }, :name => "Victoria Day", :regions => [:ca]},
|
||||
{:function => lambda { |year| ca_victoria_day(year) }, :name => "National Patriotes Day", :regions => [:ca_qc]},
|
||||
5 => [{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :name => "Victoria Day", :regions => [:ca]},
|
||||
{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :name => "National Patriotes Day", :regions => [:ca_qc]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]},
|
||||
{:mday => 1, :name => "D\xC3\xADa del Trabajo", :regions => [:mx]},
|
||||
{:mday => 5, :name => "La Batalla de Puebla", :regions => [:mx]},
|
||||
{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:ca, :us, :mx]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Easter Monday", :regions => [:ca_qc]},
|
||||
{:function => lambda { |year| easter(year)-3 }, :name => "Good Thursday", :regions => [:mx]},
|
||||
{:function => lambda { |year| easter(year) }, :name => "Easter Sunday", :regions => [:mx]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:ca, :us, :mx]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Easter Monday", :regions => [:ca_qc]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Good Thursday", :regions => [:mx]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Easter Sunday", :regions => [:mx]}],
|
||||
11 => [{:mday => 11, :name => "Rememberance Day", :regions => [:ca]},
|
||||
{:mday => 2, :name => "Dia de Muertos", :regions => [:mx]},
|
||||
{:wday => 1, :week => 3, :name => "D\xC3\xADa de la Revoluci\xC3\xB3n", :regions => [:mx]},
|
||||
|
@ -36,7 +36,7 @@ module Holidays
|
|||
{:mday => 2, :name => "New Year's", :regions => [:ca_qc]},
|
||||
{:mday => 2, :name => "New Year's Day", :regions => [:mx]},
|
||||
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
|
||||
{:function => lambda { |year| us_inauguration_day(year) }, :name => "Inauguration Day", :regions => [:us]}],
|
||||
{:function => lambda { |year| Holidays.us_inauguration_day(year) }, :name => "Inauguration Day", :regions => [:us]}],
|
||||
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ca, :mx, :us]},
|
||||
{:mday => 26, :name => "Boxing Day", :regions => [:ca]},
|
||||
{:mday => 12, :name => "Our Lady of Guadalupe's day", :regions => [:mx]}],
|
||||
|
@ -68,34 +68,7 @@ module Holidays
|
|||
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]},
|
||||
{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Monday on or before May 24
|
||||
def self.ca_victoria_day(year)
|
||||
|
@ -114,7 +87,6 @@ def self.us_inauguration_day(year)
|
|||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::NORTH_AMERICA::DEFINED_REGIONS, Holidays::NORTH_AMERICA::HOLIDAYS_BY_MONTH)
|
||||
|
|
78
lib/holidays/scandinavia.rb
Normal file
78
lib/holidays/scandinavia.rb
Normal file
|
@ -0,0 +1,78 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/dk.yaml, data/is.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'holidays/scandinavia'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module SCANDINAVIA # :nodoc:
|
||||
DEFINED_REGIONS = [:dk, :is]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
||||
{:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]},
|
||||
{:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]},
|
||||
{:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :name => "Palmesøndag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Skærtorsdag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Langfredag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "2. påskedag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+26 }, :name => "Store Bededag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+40 }, :name => "Kristi Himmelfartsdag", :regions => [:dk, :dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :name => "2. Pinsedag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+50 }, :name => "Pinsedag", :regions => [:dk, :is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-48 }, :name => "Bolludagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-47 }, :name => "Sprengidagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-46 }, :name => "Öskudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :name => "Pálmasunnudagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :name => "Skírdagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Föstudaginn langi", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :name => "Páskadagur", :regions => [:is]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Annar í páskum", :regions => [:is]}],
|
||||
11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]},
|
||||
{:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}],
|
||||
6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]},
|
||||
{:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]},
|
||||
{:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}],
|
||||
1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]},
|
||||
{:mday => 1, :name => "Nýársdagur", :regions => [:is]},
|
||||
{:mday => 6, :name => "Þrettándinn", :regions => [:is]},
|
||||
{:mday => 19, :type => :informal, :name => "Bóndadagur", :regions => [:is]}],
|
||||
12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]},
|
||||
{:mday => 24, :name => "Juleaftensdag", :regions => [:dk]},
|
||||
{:mday => 25, :name => "1. juledag", :regions => [:dk]},
|
||||
{:mday => 26, :name => "2. juledag", :regions => [:dk]},
|
||||
{:mday => 24, :name => "Jól", :regions => [:is]},
|
||||
{:mday => 25, :name => "Jól", :regions => [:is]},
|
||||
{:mday => 26, :name => "Jól", :regions => [:is]},
|
||||
{:mday => 31, :name => "Gamlárskvöld", :regions => [:is]}],
|
||||
2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}],
|
||||
8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}],
|
||||
4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]},
|
||||
{:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]},
|
||||
{:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}]
|
||||
}
|
||||
end
|
||||
|
||||
# Iceland: first day of summer (Thursday after 18 April)
|
||||
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
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::SCANDINAVIA::DEFINED_REGIONS, Holidays::SCANDINAVIA::HOLIDAYS_BY_MONTH)
|
|
@ -3,11 +3,11 @@ module Holidays
|
|||
#
|
||||
# Definitions loaded: data/united_nations.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/united_nations'
|
||||
# require 'holidays/united_nations'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module UNITED_NATIONS # :nodoc:
|
||||
|
@ -16,9 +16,9 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::UNITED_NATIONS::DEFINED_REGIONS, Holidays::UNITED_NATIONS::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/us.yaml, data/common_methods.yaml, data/north_america_informal.yaml
|
||||
# Definitions loaded: data/us.yaml, data/north_america_informal.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/us'
|
||||
# require 'holidays/us'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module US # :nodoc:
|
||||
|
@ -16,12 +16,12 @@ module Holidays
|
|||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :type => :informal, :name => "Good Friday", :regions => [:us]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :type => :informal, :name => "Good Friday", :regions => [:us]}],
|
||||
11 => [{:mday => 11, :name => "Veterans Day", :regions => [:us]},
|
||||
{:wday => 4, :week => 4, :name => "Thanksgiving Day", :regions => [:us]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:us]},
|
||||
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
|
||||
{:function => lambda { |year| us_inauguration_day(year) }, :name => "Inauguration Day", :regions => [:us]}],
|
||||
{:function => lambda { |year| Holidays.us_inauguration_day(year) }, :name => "Inauguration Day", :regions => [:us]}],
|
||||
12 => [{:mday => 25, :name => "Christmas Day", :regions => [:us]}],
|
||||
7 => [{:mday => 4, :name => "Independence Day", :regions => [:us]}],
|
||||
2 => [{:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
||||
|
@ -34,34 +34,7 @@ module Holidays
|
|||
10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
|
||||
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# January 20, every fourth year, following Presidential election
|
||||
def self.us_inauguration_day(year)
|
||||
|
@ -69,7 +42,6 @@ def self.us_inauguration_day(year)
|
|||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::US::DEFINED_REGIONS, Holidays::US::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/za.yaml, data/common_methods.yaml
|
||||
# Definitions loaded: data/za.yaml
|
||||
#
|
||||
# To use the definitions in the file, load them right after you load the
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
#
|
||||
# require 'holidays'
|
||||
# require 'path/to/za'
|
||||
# require 'holidays/za'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module ZA # :nodoc:
|
||||
|
@ -15,8 +15,8 @@ module Holidays
|
|||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Workers' Day", :regions => [:za]}],
|
||||
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:za]},
|
||||
{:function => lambda { |year| easter(year)+1 }, :name => "Family Day", :regions => [:za]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :name => "Good Friday", :regions => [:za]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :name => "Family Day", :regions => [:za]}],
|
||||
6 => [{:mday => 16, :name => "Youth Day", :regions => [:za]}],
|
||||
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:za]}],
|
||||
12 => [{:mday => 16, :name => "Day of Reconciliation", :regions => [:za]},
|
||||
|
@ -27,37 +27,9 @@ module Holidays
|
|||
9 => [{:mday => 24, :name => "Heritage Day", :regions => [:za]}],
|
||||
4 => [{:mday => 27, :name => "Freedom Day", :regions => [:za]}]
|
||||
}
|
||||
|
||||
# Get the date of Easter in a given year.
|
||||
#
|
||||
# +year+ must be a valid Gregorian year.
|
||||
#
|
||||
# Returns a Date object.
|
||||
#--
|
||||
# from http://snippets.dzone.com/posts/show/765
|
||||
# TODO: check year to ensure Gregorian
|
||||
def self.easter(year)
|
||||
y = year
|
||||
a = y % 19
|
||||
b = y / 100
|
||||
c = y % 100
|
||||
d = b / 4
|
||||
e = b % 4
|
||||
f = (b + 8) / 25
|
||||
g = (b - f + 1) / 3
|
||||
h = (19 * a + b - d - g + 15) % 30
|
||||
i = c / 4
|
||||
k = c % 4
|
||||
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||
m = (a + 11 * h + 22 * l) / 451
|
||||
month = (h + l - 7 * m + 114) / 31
|
||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||
Date.civil(year, month, day)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::ZA::DEFINED_REGIONS, Holidays::ZA::HOLIDAYS_BY_MONTH)
|
||||
|
|
51
rakefile.rb
51
rakefile.rb
|
@ -7,26 +7,28 @@ require 'lib/holidays'
|
|||
require 'bin/build_defs'
|
||||
|
||||
def_list = {
|
||||
:au => ['data/au.yaml', 'data/common_methods.yaml'],
|
||||
:ca => ['data/ca.yaml', 'data/common_methods.yaml', 'data/north_america_informal.yaml'],
|
||||
:dk => ['data/dk.yaml', 'data/common_methods.yaml'],
|
||||
:de => ['data/de.yaml', 'data/common_methods.yaml'],
|
||||
:es => ['data/es.yaml', 'data/common_methods.yaml'],
|
||||
:fr => ['data/fr.yaml', 'data/common_methods.yaml'],
|
||||
:gb => ['data/gb.yaml', 'data/common_methods.yaml'],
|
||||
:ie => ['data/ie.yaml', 'data/common_methods.yaml'],
|
||||
:is => ['data/is.yaml', 'data/common_methods.yaml'],
|
||||
:it => ['data/it.yaml', 'data/common_methods.yaml'],
|
||||
:lv => ['data/lv.yaml', 'data/common_methods.yaml'],
|
||||
:mx => ['data/mx.yaml', 'data/common_methods.yaml', 'data/north_america_informal.yaml'],
|
||||
:nl => ['data/nl.yaml', 'data/common_methods.yaml'],
|
||||
:us => ['data/us.yaml', 'data/common_methods.yaml', 'data/north_america_informal.yaml'],
|
||||
:au => ['data/au.yaml'],
|
||||
:ca => ['data/ca.yaml', 'data/north_america_informal.yaml'],
|
||||
:dk => ['data/dk.yaml'],
|
||||
:de => ['data/de.yaml'],
|
||||
:es => ['data/es.yaml'],
|
||||
:fr => ['data/fr.yaml'],
|
||||
:gb => ['data/gb.yaml'],
|
||||
:ie => ['data/ie.yaml'],
|
||||
:is => ['data/is.yaml'],
|
||||
:it => ['data/it.yaml'],
|
||||
:lv => ['data/lv.yaml'],
|
||||
:mx => ['data/mx.yaml', 'data/north_america_informal.yaml'],
|
||||
:nl => ['data/nl.yaml'],
|
||||
:us => ['data/us.yaml', 'data/north_america_informal.yaml'],
|
||||
:united_nations => ['data/united_nations.yaml'],
|
||||
:za => ['data/za.yaml', 'data/common_methods.yaml']
|
||||
:za => ['data/za.yaml']
|
||||
}
|
||||
|
||||
def_list[:north_america] = def_list[:ca] | def_list[:mx] | def_list[:us]
|
||||
|
||||
def_list[:scandinavia] = def_list[:dk] | def_list[:is]
|
||||
|
||||
def_list[:europe] = def_list[:dk] | def_list[:de] | def_list[:es] | def_list[:fr] | def_list[:gb] | def_list[:ie] | def_list[:is] | def_list[:it] |def_list[:nl] |def_list[:lv]
|
||||
|
||||
|
||||
|
@ -54,27 +56,17 @@ end
|
|||
|
||||
|
||||
task :manifest do
|
||||
File.open("MANIFEST","w") do |file|
|
||||
File.open("lib/holidays/MANIFEST","w") do |file|
|
||||
file.puts <<-EOH
|
||||
==== Regional definitions
|
||||
The following definition files are included in the default
|
||||
installation:
|
||||
|
||||
EOH
|
||||
|
||||
# def_list.each do |region, includes|
|
||||
# file.puts('* holidays/' + region.to_s)
|
||||
# includes.each do |inc|
|
||||
# file.puts(' * holidays/' + inc.gsub(/^data\/|\.yaml$/, ''))
|
||||
# end
|
||||
# end
|
||||
|
||||
FileList.new('lib/holidays/*.rb').each do |str|
|
||||
file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -83,8 +75,9 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|||
rdoc.rdoc_dir = 'doc'
|
||||
rdoc.title = 'Ruby Holidays Gem'
|
||||
rdoc.options << '--all' << '--inline-source' << '--line-numbers'
|
||||
rdoc.options << '--charset' << 'utf-8'
|
||||
rdoc.rdoc_files.include('README')
|
||||
rdoc.rdoc_files.include('MANIFEST')
|
||||
rdoc.rdoc_files.include('lib/holidays/MANIFEST')
|
||||
rdoc.rdoc_files.include('CUSTOM DATES')
|
||||
rdoc.rdoc_files.include('REFERENCES')
|
||||
rdoc.rdoc_files.include('LICENSE')
|
||||
|
@ -104,8 +97,8 @@ spec = Gem::Specification.new do |s|
|
|||
s.files = FileList["{lib}/**/*"].to_a
|
||||
s.test_files = Dir.glob('test/test_*.rb')
|
||||
s.has_rdoc = true
|
||||
s.extra_rdoc_files = ['README', 'CUSTOM DATES', 'REFERENCES', 'LICENSE']
|
||||
s.rdoc_options << '--all' << '--inline-source' << '--line-numbers'
|
||||
s.extra_rdoc_files = ['README', 'lib/holidays/MANIFEST', 'CUSTOM DATES', 'REFERENCES', 'LICENSE']
|
||||
s.rdoc_options << '--all' << '--inline-source' << '--line-numbers' << '--charset' << 'utf-8'
|
||||
end
|
||||
|
||||
desc 'Build the gem.'
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
|
||||
class CommonMethodsTests < Test::Unit::TestCase
|
||||
|
||||
def test_inclusion
|
||||
flunk
|
||||
assert_equal '1800-04-13', Holidays.easter(1800).to_s
|
||||
assert_equal '1899-04-02', Holidays.easter(1899).to_s
|
||||
assert_equal '1900-04-15', Holidays.easter(1900).to_s
|
||||
assert_equal '1999-04-04', Holidays.easter(1999).to_s
|
||||
assert_equal '2000-04-23', Holidays.easter(2000).to_s
|
||||
assert_equal '2025-04-20', Holidays.easter(2025).to_s
|
||||
assert_equal '2035-03-25', Holidays.easter(2035).to_s
|
||||
assert_equal '2067-04-03', Holidays.easter(2067).to_s
|
||||
assert_equal '2099-04-12', Holidays.easter(2099).to_s
|
||||
end
|
||||
|
||||
def test_easter_lambda
|
||||
[Date.civil(1800,4,11), Date.civil(1899,3,31), Date.civil(1900,4,13),
|
||||
Date.civil(2008,3,21), Date.civil(2035,3,23)].each do |date|
|
||||
assert_equal 'Good Friday', Holidays.on(date, :ca)[0][:name]
|
||||
end
|
||||
|
||||
[Date.civil(1800,4,14), Date.civil(1899,4,3), Date.civil(1900,4,16),
|
||||
Date.civil(2008,3,24), Date.civil(2035,3,26)].each do |date|
|
||||
assert_equal 'Easter Monday', Holidays.on(date, :ca_qc)[0][:name]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,5 +1,8 @@
|
|||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../'))
|
||||
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__), '../lib/'))
|
||||
|
||||
$KCODE = 'u'
|
||||
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'date'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
|
||||
class HolidaysTests < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@date = Date.civil(2008,1,1)
|
||||
end
|
||||
|
@ -48,22 +47,53 @@ class HolidaysTests < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_any_region
|
||||
# Should return Victoria Day and Father's Day
|
||||
# Should return Victoria Day and Father's Day.
|
||||
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
||||
assert_equal 2, holidays.length
|
||||
|
||||
# Should return Victoria Day, Father's Day and National Patriotes Day
|
||||
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :any)
|
||||
assert_equal 3, holidays.length
|
||||
# Should return Victoria Day, Father's Day and National Patriotes Day.
|
||||
#
|
||||
# Should be 3 in the CA region but other regional files are loaded during the
|
||||
# unit tests add to the :any count.
|
||||
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), [:any])
|
||||
assert holidays.length >= 3
|
||||
end
|
||||
|
||||
def test_sub_regions
|
||||
# Should return Victoria Day and Father's Day
|
||||
# Should return Victoria Day and Father's Day.
|
||||
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca)
|
||||
assert_equal 2, holidays.length
|
||||
|
||||
# Should return Victoria Day, Father's Day and National Patriotes Day
|
||||
# Should return Victoria Day, Father's Day and National Patriotes Day.
|
||||
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_qc)
|
||||
assert 3, holidays.length
|
||||
|
||||
# Should return Victoria Day, Father's Day and National Patriotes Day.
|
||||
holidays = Holidays.between(Date.civil(2008,5,1), Date.civil(2008,5,31), :ca_)
|
||||
assert_equal 3, holidays.length
|
||||
end
|
||||
|
||||
def test_easter_sunday
|
||||
assert_equal '1800-04-13', Holidays.easter(1800).to_s
|
||||
assert_equal '1899-04-02', Holidays.easter(1899).to_s
|
||||
assert_equal '1900-04-15', Holidays.easter(1900).to_s
|
||||
assert_equal '1999-04-04', Holidays.easter(1999).to_s
|
||||
assert_equal '2000-04-23', Holidays.easter(2000).to_s
|
||||
assert_equal '2025-04-20', Holidays.easter(2025).to_s
|
||||
assert_equal '2035-03-25', Holidays.easter(2035).to_s
|
||||
assert_equal '2067-04-03', Holidays.easter(2067).to_s
|
||||
assert_equal '2099-04-12', Holidays.easter(2099).to_s
|
||||
end
|
||||
|
||||
def test_easter_lambda
|
||||
[Date.civil(1800,4,11), Date.civil(1899,3,31), Date.civil(1900,4,13),
|
||||
Date.civil(2008,3,21), Date.civil(2035,3,23)].each do |date|
|
||||
assert_equal 'Good Friday', Holidays.on(date, :ca)[0][:name]
|
||||
end
|
||||
|
||||
[Date.civil(1800,4,14), Date.civil(1899,4,3), Date.civil(1900,4,16),
|
||||
Date.civil(2008,3,24), Date.civil(2035,3,26)].each do |date|
|
||||
assert_equal 'Easter Monday', Holidays.on(date, :ca_qc)[0][:name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,12 +8,6 @@ class MultipleRegionsTests < Test::Unit::TestCase
|
|||
@date = Date.civil(2008,1,1)
|
||||
end
|
||||
|
||||
def test_defining_regions
|
||||
#assert Holidays::DEFINED_REGIONS.include?(:gb)
|
||||
#assert Holidays::DEFINED_REGIONS.include?(:ie)
|
||||
#assert Holidays::DEFINED_REGIONS.include?(:gb_con)
|
||||
end
|
||||
|
||||
def test_defining_holidays
|
||||
h = Holidays.on(Date.civil(2008,12,26), :ie)
|
||||
assert_equal 'St. Stephen\'s Day', h[0][:name]
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'holidays/europe'
|
||||
|
||||
class RegionTests < Test::Unit::TestCase
|
||||
|
||||
|
||||
# ==== Netherlands
|
||||
# New Year's Day 1 January
|
||||
# Good Friday 21 March
|
||||
|
@ -28,4 +31,23 @@ class RegionTests < Test::Unit::TestCase
|
|||
assert_equal name, Holidays.on(date, :nl)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_it
|
||||
{Date.civil(2007,1,1) => 'Capodanno',
|
||||
Date.civil(2007,1,6) => 'Epifania',
|
||||
Date.civil(2007,4,8) => 'Pasqua',
|
||||
Date.civil(2007,4,9) => 'Lunedì dell\'Angelo',
|
||||
Date.civil(2007,4,25) => 'Festa della Liberazione',
|
||||
Date.civil(2007,5,1) => 'Festa dei Lavoratori',
|
||||
Date.civil(2007,6,2) => 'Festa della Repubblica',
|
||||
Date.civil(2007,8,15) => 'Assunzione',
|
||||
Date.civil(2007,11,1) => 'Ognissanti',
|
||||
Date.civil(2007,12,8) => 'Immacolata Concezione',
|
||||
Date.civil(2007,12,25) => 'Natale',
|
||||
Date.civil(2007,12,26) => 'Santo Stefano'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :it)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue