diff --git a/MANIFEST b/MANIFEST
new file mode 100644
index 0000000..8e09cf7
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,22 @@
+==== Regional definitions
+The following definition files are included in the default
+installation:
+
+* holidays/au
+* holidays/ca
+* holidays/de
+* holidays/dk
+* holidays/es
+* holidays/europe
+* holidays/fr
+* holidays/gb
+* holidays/ie
+* holidays/is
+* holidays/it
+* holidays/lv
+* holidays/mx
+* holidays/nl
+* holidays/north_america
+* holidays/united_nations
+* holidays/us
+* holidays/za
diff --git a/bin/build_defs.rb b/bin/build_defs.rb
new file mode 100644
index 0000000..c5e5274
--- /dev/null
+++ b/bin/build_defs.rb
@@ -0,0 +1,110 @@
+require 'yaml'
+
+def parse_holiday_defs(module_name, files)
+ regions = []
+ rules_by_month = {}
+ custom_methods = {}
+
+ files.each do |file|
+ def_file = YAML.load_file(file)
+ puts " Loading #{file}"
+ if def_file['months']
+ puts " - importing dates..."
+ def_file['months'].each do |month, definitions|
+ rules_by_month[month] = [] unless rules_by_month[month]
+ definitions.each do |definition|
+ rule = {}
+ definition.each do |key, val|
+ rule[key] = val
+ end
+
+ rule['regions'] = rule['regions'].collect { |r| r.to_sym }
+
+ regions << rule['regions']
+
+ exists = false
+ rules_by_month[month].each do |ex|
+ if ex['name'] == rule['name'] and ex['wday'] == rule['wday'] and ex['mday'] == rule['mday'] and ex['week'] == rule['week']
+ ex['regions'] << rule['regions'].flatten
+ exists = true
+ end
+ end
+ unless exists
+ rules_by_month[month] << rule
+ end
+
+ end # /defs.each
+ end
+ end
+ if def_file['methods']
+ puts " - importing methods..."
+ def_file['methods'].each do |name, code|
+ custom_methods[name] = code
+ end # /methods.each
+ end
+
+ end
+
+ # Build the definitions
+ month_strs = []
+ rules_by_month.each do |month, rules|
+ month_str = " #{month.to_s} => ["
+ rule_strings = []
+ rules.each do |rule|
+ str = '{'
+ if rule['mday']
+ str << ":mday => #{rule['mday']}, "
+ elsif rule['function']
+ str << ":function => #{rule['function']}, "
+ else
+ str << ":wday => #{rule['wday']}, :week => #{rule['week']}, "
+ end
+
+ # shouldn't allow the same region twice
+ str << ":name => \"#{rule['name']}\", :regions => [:" + rule['regions'].uniq.join(', :') + "]}"
+ rule_strings << str
+ end
+ month_str << rule_strings.join(",\n ") + "]"
+ month_strs << month_str
+ end
+
+ month_strs.join(",\n")
+
+
+ # Build the methods
+ method_str = ''
+ custom_methods.each do |key, code|
+ method_str << code + "\n\n"
+ end
+
+
+ # Build the output file
+ out =<<-EOC
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: #{files.join(', ')}
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/#{module_name.downcase}'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module #{module_name} # :nodoc:
+ DEFINED_REGIONS = [:#{regions.flatten.uniq.join(', :')}]
+
+ HOLIDAYS_BY_MONTH = {
+#{month_strs.join(",\n")}
+ }
+
+#{method_str}
+ end
+end
+
+Holidays.merge_defs(Holidays::#{module_name}::DEFINED_REGIONS, Holidays::#{module_name}::HOLIDAYS_BY_MONTH)
+ EOC
+
+
+end
\ No newline at end of file
diff --git a/create_defs.rb b/create_defs.rb
deleted file mode 100644
index d9b5fc2..0000000
--- a/create_defs.rb
+++ /dev/null
@@ -1,119 +0,0 @@
-require 'yaml'
-
-#module_name = 'NorthAmerica'
-#files = ['data/ca.yaml', 'data/mx.yaml', 'data/us.yaml', 'data/common_methods.yaml', 'data/north_america_informal.yaml']
-
-#module_name = 'Europe'
-#files = ['data/dk.yaml', 'data/es.yaml', 'data/fr.yaml', 'data/gb.yaml', 'data/ie.yaml', 'data/is.yaml', 'data/common_methods.yaml']
-
-module_name = 'CA'
-files = ['data/ca.yaml', 'data/common_methods.yaml', 'data/north_america_informal.yaml']
-
-regions = []
-rules_by_month = {}
-custom_methods = {}
-
-files.each do |file|
- def_file = YAML.load_file(file)
- puts "Loading #{file}"
- if def_file['months']
- puts " importing dates..."
- def_file['months'].each do |month, definitions|
- rules_by_month[month] = [] unless rules_by_month[month]
- definitions.each do |definition|
- rule = {}
- definition.each do |key, val|
- rule[key] = val
- end
-
- rule['regions'] = rule['regions'].collect { |r| r.to_sym }
-
- regions << rule['regions']
-
- exists = false
- rules_by_month[month].each do |ex|
- if ex['name'] == rule['name'] and ex['wday'] == rule['wday'] and ex['mday'] == rule['mday'] and ex['week'] == rule['week']
- ex['regions'] << rule['regions'].flatten
- exists = true
- end
- end
- unless exists
- rules_by_month[month] << rule
- end
-
- end # /defs.each
- end
- end
- if def_file['methods']
- puts " importing methods..."
- def_file['methods'].each do |name, code|
- custom_methods[name] = code
- end # /methods.each
- end
-
-end
-
-# Build the definitions
-month_strs = []
-rules_by_month.each do |month, rules|
- month_str = " #{month.to_s} => ["
- rule_strings = []
- rules.each do |rule|
- str = '{'
- if rule['mday']
- str << ":mday => #{rule['mday']}, "
- elsif rule['function']
- str << ":function => #{rule['function']}, "
- else
- str << ":wday => #{rule['wday']}, :week => #{rule['week']}, "
- end
-
- # shouldn't allow the same region twice
- str << ":name => \"#{rule['name']}\", :regions => [:" + rule['regions'].uniq.join(', :') + "]}"
- rule_strings << str
- end
- month_str << rule_strings.join(",\n ") + "]"
- month_strs << month_str
-end
-
-month_strs.join(",\n")
-
-
-# Build the methods
-method_str = ''
-custom_methods.each do |key, code|
- method_str << code + "\n\n"
-end
-
-
-# Build the output file
-out =<<-EOC
-module Holidays
- # This file is generated by the Ruby Holiday gem.
- #
- # Definitions loaded: #{files.join(', ')}
- #
- # To use the definitions in the file, load them right after you load the
- # Holiday gem:
- #
- # require 'holidays'
- # require 'path/to/#{module_name.downcase}'
- #
- # More definitions are available at http://code.dunae.ca/holidays.
- module #{module_name} # :nodoc:
- DEFINED_REGIONS = [:#{regions.flatten.uniq.join(', :')}]
-
- HOLIDAYS_BY_MONTH = {
-#{month_strs.join(",\n")}
- }
-
-#{method_str}
- end
-end
-
-Holidays.merge_defs(Holidays::#{module_name}::DEFINED_REGIONS, Holidays::#{module_name}::HOLIDAYS_BY_MONTH)
-EOC
-
-File.open("test_file.rb","w") do |file|
- file.puts out
-end
\ No newline at end of file
diff --git a/data/de.yaml b/data/de.yaml
new file mode 100644
index 0000000..2e1124c
--- /dev/null
+++ b/data/de.yaml
@@ -0,0 +1,59 @@
+# German holiday definitions for the Ruby Holiday gem.
+#
+# Updated: 2008-11-23.
+# Sources:
+# - http://en.wikipedia.org/wiki/Holidays_in_Germany
+---
+months:
+ 0:
+ - name: Karfreitag
+ regions: [de]
+ function: lambda { |year| easter(year)-2 }
+ - name: Ostermontag
+ regions: [de]
+ function: lambda { |year| easter(year)+1 }
+ - name: Christi Himmelfahrt
+ regions: [de]
+ function: lambda { |year| easter(year)+39 }
+ - name: Pfingstmontag
+ regions: [de]
+ function: lambda { |year| 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 }
+ 1:
+ - name: Neujahrstag
+ regions: [de]
+ mday: 1
+ - name: Heilige Drei Könige
+ regions: [de_bw, de_by]
+ mday: 6
+ 5:
+ - name: Tag der Arbeit
+ regions: [de]
+ mday: 1
+ - name: Victoire 1945
+ regions: [de]
+ mday: 8
+ 8:
+ - name: Mariä Himmelfahrt
+ regions: [de_by]
+ mday: 15
+ 10:
+ - name: Tag der Deutschen Einheit
+ regions: [de]
+ mday: 3
+ - name: Reformationstag
+ regions: [de_bb, de_mv, de_sn, de_st, de_th]
+ mday: 31
+ 11:
+ - name: Allerheiligen
+ regions: [de_bw, de_by, de_nw, de_rp, de_sl]
+ mday: 1
+ 12:
+ - name: 1. Weihnachtstag
+ regions: [de]
+ mday: 25
+ - name: 2. Weihnachtstag
+ regions: [de]
+ mday: 25
diff --git a/data/it.yaml b/data/it.yaml
new file mode 100644
index 0000000..03f2153
--- /dev/null
+++ b/data/it.yaml
@@ -0,0 +1,51 @@
+# Italian holiday definitions for the Ruby Holiday gem.
+#
+# Updated: 2008-11-23.
+# Sources:
+# - http://en.wikipedia.org/wiki/Holidays_in_Italy
+---
+months:
+ 0:
+ - name: Pasqua
+ regions: [it]
+ function: lambda { |year| easter(year) }
+ - name: Lunedì dell'Angelo
+ regions: [it]
+ function: lambda { |year| easter(year)+1 }
+ 1:
+ - name: Capodanno
+ regions: [it]
+ mday: 1
+ - name: Epifania
+ regions: [it]
+ mday: 6
+ 4:
+ - name: Festa della Liberazione
+ regions: [it]
+ mday: 25
+ 5:
+ - name: Festa dei Lavoratori
+ regions: [it]
+ mday: 1
+ 6:
+ - name: Festa della Repubblica
+ regions: [it]
+ mday: 2
+ 8:
+ - name: Assunzione
+ regions: [it]
+ mday: 15
+ 11:
+ - name: Ognissanti
+ regions: [it]
+ mday: 1
+ 12:
+ - name: Immacolata Concezione
+ regions: [it]
+ mday: 8
+ - name: Natale
+ regions: [it]
+ mday: 25
+ - name: Santo Stefano
+ regions: [it]
+ mday: 26
diff --git a/data/lv.yaml b/data/lv.yaml
new file mode 100644
index 0000000..14024e2
--- /dev/null
+++ b/data/lv.yaml
@@ -0,0 +1,49 @@
+# Latvian holiday definitions for the Ruby Holiday gem.
+#
+# Updated: 2008-11-23.
+# Sources:
+# - http://en.wikipedia.org/wiki/Holidays_in_Latvia
+---
+months:
+ 0:
+ - name: Liela Piektdiena
+ regions: [lv]
+ function: lambda { |year| easter(year)-2 }
+ - name: Lieldienas
+ regions: [lv]
+ function: lambda { |year| easter(year) }
+ - name: 2. Lieldienas
+ regions: [lv]
+ function: lambda { |year| easter(year)+1 }
+ 1:
+ - name: Jaunais Gads
+ regions: [lv]
+ mday: 1
+ 5:
+ - name: Darba svetki
+ regions: [lv]
+ mday: 1
+ - name: Neatkaribas deklaracijas pasludinašanas diena
+ regions: [lv]
+ mday: 4
+ 6:
+ - name: Ligo Diena
+ regions: [lv]
+ mday: 23
+ - name: Jani
+ regions: [lv]
+ mday: 24
+ 11:
+ - name: Latvijas Republikas proklamešanas diena
+ regions: [lv]
+ mday: 18
+ 12:
+ - name: Ziemassvetki
+ regions: [lv]
+ mday: 25
+ - name: 2. Ziemassvetki
+ regions: [lv]
+ mday: 25
+ - name: Vecgada vakars
+ regions: [lv]
+ mday: 31
\ No newline at end of file
diff --git a/data/nl.yaml b/data/nl.yaml
new file mode 100644
index 0000000..4b2994a
--- /dev/null
+++ b/data/nl.yaml
@@ -0,0 +1,51 @@
+# Dutch holiday definitions for the Ruby Holiday gem.
+#
+# Updated: 2008-11-23.
+# Sources:
+# - http://en.wikipedia.org/wiki/Public_holidays_in_the_Netherlands
+---
+months:
+ 0:
+ - name: Goede Vrijdag
+ regions: [nl]
+ function: lambda { |year| easter(year)-2 }
+ - name: Pasen
+ regions: [nl]
+ function: lambda { |year| easter(year) }
+ - name: Pasen
+ regions: [nl]
+ function: lambda { |year| easter(year)+1 }
+ - name: Hemelvaartsdag
+ regions: [nl]
+ function: lambda { |year| easter(year)+40 }
+ - name: Pinksteren
+ regions: [nl]
+ function: lambda { |year| easter(year)+49 }
+ - name: Pinksteren
+ regions: [nl]
+ function: lambda { |year| easter(year)+50 }
+ 1:
+ - name: Nieuwjaar
+ regions: [nl]
+ mday: 1
+ 4:
+ - name: Koninginnedag
+ regions: [nl]
+ mday: 30
+ 5:
+ - name: Dodenherdenking
+ regions: [nl]
+ mday: 4
+ - name: Bevrijdingsdag
+ regions: [nl]
+ mday: 5
+ 12:
+ - name: Sinterklaas
+ regions: [nl]
+ mday: 5
+ - name: Kerstmis
+ regions: [nl]
+ mday: 25
+ - name: Kerstmis
+ regions: [nl]
+ mday: 26
diff --git a/data/un.yaml b/data/united_nations.yaml
similarity index 100%
rename from data/un.yaml
rename to data/united_nations.yaml
diff --git a/lib/holidays.rb b/lib/holidays.rb
index 082c7aa..d36d1e7 100644
--- a/lib/holidays.rb
+++ b/lib/holidays.rb
@@ -1,5 +1,7 @@
$:.unshift File.dirname(__FILE__)
+require 'digest/md5'
+
module Holidays
# Exception thrown when an unknown region is requested.
class UnkownRegionError < ArgumentError; end
@@ -8,6 +10,7 @@ module Holidays
@@regions = []
@@holidays_by_month = {}
+ @@proc_cache = {}
WEEKS = {:first => 1, :second => 2, :third => 3, :fourth => 4, :fifth => 5, :last => -1}
MONTH_LENGTHS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
@@ -61,7 +64,8 @@ module Holidays
next unless in_region?(regions, h[:regions])
if h[:function]
- result = h[:function].call(year)
+ #result = h[:function].call(year)
+ result = call_proc(h[:function], year)
if result.kind_of?(Date)
month = result.month
mday = result.mday
@@ -129,6 +133,39 @@ private
available.any? { |r| requested.include?(r) }
end
+
+
+
+ # Call a proc function defined in a holiday definition file.
+ #
+ # Procs are cached.
+ #
+ # ==== Benchmarks
+ #
+ # Lookup Easter Sunday, with caching, by number of iterations:
+ #
+ # user system total real
+ # 0001 0.000000 0.000000 0.000000 ( 0.000000)
+ # 0010 0.000000 0.000000 0.000000 ( 0.000000)
+ # 0100 0.078000 0.000000 0.078000 ( 0.078000)
+ # 1000 0.641000 0.000000 0.641000 ( 0.641000)
+ # 5000 3.172000 0.015000 3.187000 ( 3.219000)
+ #
+ # Lookup Easter Sunday, without caching, by number of iterations:
+ #
+ # user system total real
+ # 0001 0.000000 0.000000 0.000000 ( 0.000000)
+ # 0010 0.016000 0.000000 0.016000 ( 0.016000)
+ # 0100 0.125000 0.000000 0.125000 ( 0.125000)
+ # 1000 1.234000 0.000000 1.234000 ( 1.234000)
+ # 5000 6.094000 0.031000 6.125000 ( 6.141000)
+ def self.call_proc(function, year) # :nodoc:
+ proc_key = Digest::MD5.hexdigest("#{function.to_s}_#{year.to_s}")
+ @@proc_cache[proc_key] = function.call(year) unless @@proc_cache[proc_key]
+ @@proc_cache[proc_key]
+ end
+
+
end
@@ -164,24 +201,27 @@ class Date
# week.
#
# ==== Parameters
- # [year] Integer.
+ # [year] Integer.
# [month] Integer from 1-12.
- # [week] One of :first, :second, :third,
- # :fourth or :fifth.
- # [wday] Day of the week as an integer from 0 (Sunday) to 6
- # (Saturday) or as a symbol (e.g. :monday).
+ # [week] One of :first, :second, :third,
+ # :fourth or :fifth.
+ # [wday] Day of the week as an integer from 0 (Sunday) to 6
+ # (Saturday) or as a symbol (e.g. :monday).
#
# Returns an integer.
#
# ===== Examples
# First Monday of January, 2008:
# calculate_mday(2008, 1, :first, :monday)
+ # => 7
#
# Third Thursday of December, 2008:
# calculate_mday(2008, 12, :third, 4)
+ # => 18
#
# Last Monday of January, 2008:
# calculate_mday(2008, 1, :last, 1)
+ # => 28
#--
# see http://www.irt.org/articles/js050/index.htm
def self.calculate_mday(year, month, week, wday)
diff --git a/lib/holidays/au.rb b/lib/holidays/au.rb
new file mode 100644
index 0000000..636b749
--- /dev/null
+++ b/lib/holidays/au.rb
@@ -0,0 +1,76 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/au.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/au'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module AU # :nodoc:
+ DEFINED_REGIONS = [:au_qld, :au_nt, :au, :au_tas, :au_wa, :au_vic, :au_act, :au_nsw, :au_sa]
+
+ 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, :au_tas]}],
+ 6 => [{:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au]},
+ {:mday => 6, :name => "Queensland Day", :regions => [:au_qld]}],
+ 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:au]},
+ {:mday => 26, :name => "Australia Day", :regions => [:au]}],
+ 12 => [{:mday => 25, :name => "Christmas Day", :regions => [:au]},
+ {:mday => 26, :name => "Boxing Day", :regions => [:au]}],
+ 3 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_wa]},
+ {:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic, :au_tas]}],
+ 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
+
+
+# Monday on or before May 24
+def self.ca_victoria_day(year)
+ date = Date.civil(year,5,24)
+ if date.wday > 1
+ date -= (date.wday - 1)
+ elsif date.wday == 0
+ date -= 6
+ end
+ date
+end
+
+
+ end
+end
+
+Holidays.merge_defs(Holidays::AU::DEFINED_REGIONS, Holidays::AU::HOLIDAYS_BY_MONTH)
diff --git a/lib/holidays/ca.rb b/lib/holidays/ca.rb
index 9df600f..14c7661 100644
--- a/lib/holidays/ca.rb
+++ b/lib/holidays/ca.rb
@@ -1,95 +1,95 @@
-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
- #
- # To use the definitions in the file, load them right after you load the
- # Holiday gem:
- #
- # require 'holidays'
- # require 'path/to/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]},
- {:wday => 0, :week => 3, :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]}],
- 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]},
- {:mday => 21, :name => "National Aboriginal Day", :regions => [:ca_nt]}],
- 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca]},
- {:mday => 2, :name => "New Year's", :regions => [:ca_qc]}],
- 12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ca]},
- {:mday => 26, :name => "Boxing Day", :regions => [:ca]}],
- 7 => [{:mday => 1, :name => "Canada Day", :regions => [:ca]},
- {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
- {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]}],
- 2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
- {:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
- {:mday => 2, :name => "Groundhog Day", :regions => [:us, :ca]},
- {:mday => 14, :name => "Valentine's Day", :regions => [:us, :ca]}],
- 8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
- {:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
- {:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
- {:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
- {:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
- {:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
- 3 => [{:mday => 23, :name => "St. George's Day", :regions => [:ca_nf]},
- {:mday => 17, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
- 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]}],
- 4 => [{:mday => 1, :name => "April Fool's Day", :regions => [:us, :ca]},
- {:mday => 22, :name => "Earth Day", :regions => [:us, :ca]}],
- 10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
- {:mday => 31, :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
-
-
-# Monday on or before May 24
-def self.ca_victoria_day(year)
- date = Date.civil(year,5,24)
- if date.wday > 1
- date -= (date.wday - 1)
- elsif date.wday == 0
- date -= 6
- end
- date
-end
-
-
- end
-end
-
-Holidays.merge_defs(Holidays::CA::DEFINED_REGIONS, Holidays::CA::HOLIDAYS_BY_MONTH)
+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
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/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]},
+ {:wday => 0, :week => 3, :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]}],
+ 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]},
+ {:mday => 21, :name => "National Aboriginal Day", :regions => [:ca_nt]}],
+ 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca]},
+ {:mday => 2, :name => "New Year's", :regions => [:ca_qc]}],
+ 12 => [{:mday => 25, :name => "Christmas Day", :regions => [:ca]},
+ {:mday => 26, :name => "Boxing Day", :regions => [:ca]}],
+ 7 => [{:mday => 1, :name => "Canada Day", :regions => [:ca]},
+ {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
+ {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]}],
+ 2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
+ {:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
+ {:mday => 2, :name => "Groundhog Day", :regions => [:us, :ca]},
+ {:mday => 14, :name => "Valentine's Day", :regions => [:us, :ca]}],
+ 8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
+ {:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
+ {:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
+ {:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
+ {:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
+ {:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
+ 3 => [{:mday => 23, :name => "St. George's Day", :regions => [:ca_nf]},
+ {:mday => 17, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
+ 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]}],
+ 4 => [{:mday => 1, :name => "April Fool's Day", :regions => [:us, :ca]},
+ {:mday => 22, :name => "Earth Day", :regions => [:us, :ca]}],
+ 10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
+ {:mday => 31, :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
+
+
+# Monday on or before May 24
+def self.ca_victoria_day(year)
+ date = Date.civil(year,5,24)
+ if date.wday > 1
+ date -= (date.wday - 1)
+ elsif date.wday == 0
+ date -= 6
+ end
+ date
+end
+
+
+ end
+end
+
+Holidays.merge_defs(Holidays::CA::DEFINED_REGIONS, Holidays::CA::HOLIDAYS_BY_MONTH)
diff --git a/lib/holidays/de.rb b/lib/holidays/de.rb
new file mode 100644
index 0000000..ee52028
--- /dev/null
+++ b/lib/holidays/de.rb
@@ -0,0 +1,66 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/de.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/de'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module DE # :nodoc:
+ DEFINED_REGIONS = [:de, :de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_he, :de_sn, :de_th, :de_bb, :de_mv, :de_st]
+
+ 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]}],
+ 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]}],
+ 12 => [{:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]},
+ {:mday => 25, :name => "2. Weihnachtstag", :regions => [:de]}],
+ 8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by]}],
+ 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)
diff --git a/lib/holidays/dk.rb b/lib/holidays/dk.rb
new file mode 100644
index 0000000..0e435b5
--- /dev/null
+++ b/lib/holidays/dk.rb
@@ -0,0 +1,75 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/dk.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/dk'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module DK # :nodoc:
+ DEFINED_REGIONS = [:dk, :dk_]
+
+ HOLIDAYS_BY_MONTH = {
+ 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
+ {:mday => 5, :name => "Danmarks befrielse", :regions => [:dk]}],
+ 0 => [{:function => lambda { |year| easter(year)-49 }, :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]}],
+ 11 => [{:mday => 10, :name => "Mortensaften", :regions => [:dk]}],
+ 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]},
+ {:mday => 15, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]},
+ {:mday => 23, :name => "Sankt Hans aften", :regions => [:dk]}],
+ 1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]}],
+ 12 => [{:mday => 13, :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_]}],
+ 4 => [{:mday => 1, :name => "1. april", :regions => [:dk]},
+ {:mday => 9, :name => "Danmarks besættelse", :regions => [:dk]},
+ {:mday => 16, :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)
diff --git a/lib/holidays/es.rb b/lib/holidays/es.rb
new file mode 100644
index 0000000..c966ec3
--- /dev/null
+++ b/lib/holidays/es.rb
@@ -0,0 +1,80 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/es.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/es'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module ES # :nodoc:
+ DEFINED_REGIONS = [: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]
+
+ HOLIDAYS_BY_MONTH = {
+ 5 => [{:mday => 1, :name => "Día del Trabajador", :regions => [:es]},
+ {: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]}],
+ 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]}],
+ 1 => [{:mday => 1, :name => "Año Nuevo", :regions => [:es]},
+ {:mday => 6, :name => "Día de Reyes", :regions => [:es]}],
+ 12 => [{:mday => 6, :name => "Día de la Constitución", :regions => [:es]},
+ {:mday => 8, :name => "Inmaculada Concepción", :regions => [:es]},
+ {:mday => 25, :name => "Navidad del Señor", :regions => [:es]},
+ {:mday => 26, :name => "San Esteban", :regions => [:es_ib, :es_ct]}],
+ 7 => [{:mday => 23, :name => "Santiago Apostol", :regions => [:es_ga]}],
+ 2 => [{:mday => 28, :name => "Día de Andalucía", :regions => [:es_an]}],
+ 8 => [{:mday => 15, :name => "Asunción", :regions => [:es]}],
+ 3 => [{:mday => 1, :name => "Día de las Islas Baleares", :regions => [:es_ib]},
+ {:mday => 19, :name => "San José", :regions => [:es_v, :es_vc, :es_cm, :es_mu, :es_m]}],
+ 9 => [{:mday => 2, :name => "Día de Ceuta", :regions => [:es_ce]},
+ {:mday => 8, :name => "Día de Asturias", :regions => [:es_o]},
+ {:mday => 8, :name => "Día de Extremadura", :regions => [:es_ex]},
+ {:mday => 11, :name => "Fiesta Nacional de Cataluña", :regions => [:es_ct]}],
+ 4 => [{:mday => 23, :name => "San Jorge", :regions => [:es_ar, :es_cl]},
+ {:mday => 23, :name => "Día de Aragón", :regions => [:es_ar]}],
+ 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)
diff --git a/lib/holidays/europe.rb b/lib/holidays/europe.rb
new file mode 100644
index 0000000..2a31a12
--- /dev/null
+++ b/lib/holidays/europe.rb
@@ -0,0 +1,216 @@
+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
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/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]
+
+ HOLIDAYS_BY_MONTH = {
+ 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
+ {:mday => 5, :name => "Danmarks befrielse", :regions => [:dk]},
+ {:mday => 1, :name => "Tag der Arbeit", :regions => [:de]},
+ {:mday => 8, :name => "Victoire 1945", :regions => [:de, :fr]},
+ {:mday => 1, :name => "Día del Trabajador", :regions => [:es]},
+ {: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]},
+ {:mday => 1, :name => "Fête du travail", :regions => [:fr]},
+ {:wday => 1, :week => 1, :name => "May Day", :regions => [:gb, :ie]},
+ {:mday => 9, :name => "Liberation Day", :regions => [:je, :gb_jsy, :gg, :gb_gsy]},
+ {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb]},
+ {:mday => 3, :name => "Sjómannadagurinn", :regions => [:is]},
+ {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]},
+ {:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]},
+ {:mday => 4, :name => "Dodenherdenking", :regions => [:nl]},
+ {: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 }, :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, :nl]},
+ {:function => lambda { |year| easter(year)+40 }, :name => "Hemelvaartsdag", :regions => [:nl]},
+ {:function => lambda { |year| easter(year)+49 }, :name => "Pinksteren", :regions => [:nl, :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]}],
+ 11 => [{:mday => 10, :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]},
+ {:mday => 1, :name => "Toussaint", :regions => [:fr]},
+ {:mday => 11, :name => "Armistice 1918", :regions => [:fr]},
+ {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]},
+ {:mday => 1, :name => "Ognissanti", :regions => [:it]},
+ {:mday => 18, :name => "Latvijas Republikas proklamešanas diena", :regions => [:lv]}],
+ 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]},
+ {:mday => 15, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]},
+ {:mday => 23, :name => "Sankt Hans aften", :regions => [:dk]},
+ {: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]},
+ {:wday => 1, :week => 1, :name => "Labour Day/May Day", :regions => [:ie]},
+ {:mday => 2, :name => "Festa della Repubblica", :regions => [:it]},
+ {:mday => 23, :name => "Ligo Diena", :regions => [:lv]},
+ {:mday => 24, :name => "Jani", :regions => [:lv]}],
+ 1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]},
+ {:mday => 1, :name => "Neujahrstag", :regions => [:de]},
+ {:mday => 6, :name => "Heilige Drei Könige", :regions => [:de_bw, :de_by]},
+ {:mday => 1, :name => "Año Nuevo", :regions => [:es]},
+ {:mday => 6, :name => "Día de Reyes", :regions => [:es]},
+ {:mday => 1, :name => "Jour de l'an", :regions => [:fr]},
+ {:mday => 1, :name => "New Year's Day", :regions => [:gb, :ie]},
+ {:mday => 2, :name => "New Year's", :regions => [:gb_sct]},
+ {:mday => 1, :name => "Nýársdagur", :regions => [:is]},
+ {:mday => 6, :name => "Þrettándinn", :regions => [:is]},
+ {:mday => 19, :name => "Bóndadagur", :regions => [:is]},
+ {:mday => 1, :name => "Capodanno", :regions => [:it]},
+ {:mday => 6, :name => "Epifania", :regions => [:it]},
+ {:mday => 1, :name => "Nieuwjaar", :regions => [:nl]},
+ {:mday => 1, :name => "Jaunais Gads", :regions => [:lv]}],
+ 12 => [{:mday => 13, :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 => 25, :name => "1. Weihnachtstag", :regions => [:de]},
+ {:mday => 25, :name => "2. Weihnachtstag", :regions => [:de]},
+ {:mday => 6, :name => "Día de la Constitución", :regions => [:es]},
+ {:mday => 8, :name => "Inmaculada Concepción", :regions => [:es]},
+ {:mday => 25, :name => "Navidad del Señor", :regions => [:es]},
+ {:mday => 26, :name => "San Esteban", :regions => [:es_ib, :es_ct]},
+ {:mday => 25, :name => "Nöel", :regions => [:fr]},
+ {:mday => 25, :name => "Christmas Day", :regions => [:gb, :ie]},
+ {:mday => 26, :name => "Boxing Day", :regions => [:gb]},
+ {:mday => 26, :name => "St. Stephen's Day", :regions => [:ie]},
+ {: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]},
+ {:mday => 8, :name => "Immacolata Concezione", :regions => [:it]},
+ {:mday => 25, :name => "Natale", :regions => [:it]},
+ {:mday => 26, :name => "Santo Stefano", :regions => [:it]},
+ {:mday => 5, :name => "Sinterklaas", :regions => [:nl]},
+ {:mday => 25, :name => "Kerstmis", :regions => [:nl]},
+ {:mday => 26, :name => "Kerstmis", :regions => [:nl]},
+ {:mday => 25, :name => "Ziemassvetki", :regions => [:lv]},
+ {:mday => 25, :name => "2. Ziemassvetki", :regions => [:lv]},
+ {:mday => 31, :name => "Vecgada vakars", :regions => [:lv]}],
+ 7 => [{:mday => 23, :name => "Santiago Apostol", :regions => [:es_ga]},
+ {:mday => 14, :name => "Fête nationale", :regions => [:fr]},
+ {:mday => 5, :name => "Tynwald Day", :regions => [:im, :gb_iom]},
+ {:mday => 12, :name => "Battle of the Boyne", :regions => [:gb_nir]}],
+ 2 => [{:mday => 28, :name => "Día de Andalucía", :regions => [:es_an]},
+ {:mday => 18, :name => "Konudagur", :regions => [:is]}],
+ 8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by]},
+ {:mday => 15, :name => "Asunción", :regions => [:es]},
+ {:mday => 15, :name => "Assomption", :regions => [:fr]},
+ {:wday => 1, :week => 1, :name => "Bank Holiday", :regions => [:gb_sct]},
+ {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb_eng, :gb_wls, :gb_eaw]},
+ {:wday => 1, :week => 1, :name => "August Holiday", :regions => [:ie]},
+ {:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]},
+ {:mday => 15, :name => "Assunzione", :regions => [:it]}],
+ 3 => [{:mday => 1, :name => "Día de las Islas Baleares", :regions => [:es_ib]},
+ {:mday => 19, :name => "San José", :regions => [:es_v, :es_vc, :es_cm, :es_mu, :es_m]},
+ {:mday => 5, :name => "St. Piran's Day", :regions => [:gb_con]},
+ {:mday => 17, :name => "St. Patrick's Day", :regions => [:gb_nir, :ie]}],
+ 9 => [{:mday => 2, :name => "Día de Ceuta", :regions => [:es_ce]},
+ {:mday => 8, :name => "Día de Asturias", :regions => [:es_o]},
+ {:mday => 8, :name => "Día de Extremadura", :regions => [:es_ex]},
+ {:mday => 11, :name => "Fiesta Nacional de Cataluña", :regions => [:es_ct]}],
+ 4 => [{:mday => 1, :name => "1. april", :regions => [:dk]},
+ {:mday => 9, :name => "Danmarks besættelse", :regions => [:dk]},
+ {:mday => 16, :name => "Dronningens fødselsdag", :regions => [:dk]},
+ {:mday => 23, :name => "San Jorge", :regions => [:es_ar, :es_cl]},
+ {:mday => 23, :name => "Día de Aragón", :regions => [:es_ar]},
+ {:mday => 25, :name => "Festa della Liberazione", :regions => [:it]},
+ {:mday => 30, :name => "Koninginnedag", :regions => [:nl]}],
+ 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]},
+ {:mday => 9, :name => "Día de Valencia", :regions => [:es_vc, :es_v]},
+ {:mday => 12, :name => "Día de la Hispanidad", :regions => [:es]},
+ {:wday => 1, :week => -1, :name => "October Holiday", :regions => [:ie]}]
+ }
+
+# 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
+
+# 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)
diff --git a/lib/holidays/fr.rb b/lib/holidays/fr.rb
new file mode 100644
index 0000000..bb38997
--- /dev/null
+++ b/lib/holidays/fr.rb
@@ -0,0 +1,63 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/fr.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/fr'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module FR # :nodoc:
+ DEFINED_REGIONS = [:fr]
+
+ 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]}],
+ 11 => [{:mday => 1, :name => "Toussaint", :regions => [:fr]},
+ {:mday => 11, :name => "Armistice 1918", :regions => [:fr]}],
+ 1 => [{:mday => 1, :name => "Jour de l'an", :regions => [:fr]}],
+ 12 => [{:mday => 25, :name => "Nöel", :regions => [:fr]}],
+ 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)
diff --git a/lib/holidays/gb.rb b/lib/holidays/gb.rb
index 83d1d5d..363149b 100644
--- a/lib/holidays/gb.rb
+++ b/lib/holidays/gb.rb
@@ -1,67 +1,67 @@
-module Holidays
- # This file is generated by the Ruby Holiday gem.
- #
- # Definitions loaded: data/gb.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/gb'
- #
- # More definitions are available at http://code.dunae.ca/holidays.
- module GB # :nodoc:
- DEFINED_REGIONS = [:gb, :je, :gb_jsy, :gg, :gb_gsy, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :im, :gb_iom, :gb_con]
-
- HOLIDAYS_BY_MONTH = {
- 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]}],
- 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]},
- {:mday => 26, :name => "Boxing Day", :regions => [:gb]}],
- 7 => [{:mday => 5, :name => "Tynwald Day", :regions => [:im, :gb_iom]},
- {:mday => 12, :name => "Battle of the Boyne", :regions => [:gb_nir]}],
- 8 => [{:wday => 1, :week => 1, :name => "Bank Holiday", :regions => [:gb_sct]},
- {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb_eng, :gb_wls, :gb_eaw]}],
- 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)
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/gb.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/gb'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module GB # :nodoc:
+ DEFINED_REGIONS = [:gb, :je, :gb_jsy, :gg, :gb_gsy, :gb_eng, :gb_wls, :gb_eaw, :gb_nir, :gb_sct, :im, :gb_iom, :gb_con]
+
+ HOLIDAYS_BY_MONTH = {
+ 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]}],
+ 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]},
+ {:mday => 26, :name => "Boxing Day", :regions => [:gb]}],
+ 7 => [{:mday => 5, :name => "Tynwald Day", :regions => [:im, :gb_iom]},
+ {:mday => 12, :name => "Battle of the Boyne", :regions => [:gb_nir]}],
+ 8 => [{:wday => 1, :week => 1, :name => "Bank Holiday", :regions => [:gb_sct]},
+ {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb_eng, :gb_wls, :gb_eaw]}],
+ 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)
diff --git a/lib/holidays/ie.rb b/lib/holidays/ie.rb
index c338f8e..fe325ac 100644
--- a/lib/holidays/ie.rb
+++ b/lib/holidays/ie.rb
@@ -1,60 +1,60 @@
-module Holidays
- # This file is generated by the Ruby Holiday gem.
- #
- # Definitions loaded: data/ie.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/ie'
- #
- # More definitions are available at http://code.dunae.ca/holidays.
- module IE # :nodoc:
- DEFINED_REGIONS = [:ie]
-
- 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]}],
- 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]},
- {:mday => 26, :name => "St. Stephen's Day", :regions => [:ie]}],
- 8 => [{:wday => 1, :week => 1, :name => "August Holiday", :regions => [:ie]}],
- 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)
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/ie.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/ie'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module IE # :nodoc:
+ DEFINED_REGIONS = [:ie]
+
+ 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]}],
+ 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]},
+ {:mday => 26, :name => "St. Stephen's Day", :regions => [:ie]}],
+ 8 => [{:wday => 1, :week => 1, :name => "August Holiday", :regions => [:ie]}],
+ 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)
diff --git a/lib/holidays/is.rb b/lib/holidays/is.rb
new file mode 100644
index 0000000..65b6ae9
--- /dev/null
+++ b/lib/holidays/is.rb
@@ -0,0 +1,86 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/is.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/is'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module IS # :nodoc:
+ DEFINED_REGIONS = [:is]
+
+ HOLIDAYS_BY_MONTH = {
+ 5 => [{:mday => 3, :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]}],
+ 11 => [{:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}],
+ 1 => [{:mday => 1, :name => "Nýársdagur", :regions => [:is]},
+ {:mday => 6, :name => "Þrettándinn", :regions => [:is]},
+ {:mday => 19, :name => "Bóndadagur", :regions => [:is]}],
+ 12 => [{: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, :name => "Konudagur", :regions => [:is]}],
+ 8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}]
+ }
+
+# 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
+
+# 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)
diff --git a/lib/holidays/it.rb b/lib/holidays/it.rb
new file mode 100644
index 0000000..9ea65ed
--- /dev/null
+++ b/lib/holidays/it.rb
@@ -0,0 +1,63 @@
+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)
diff --git a/lib/holidays/lv.rb b/lib/holidays/lv.rb
new file mode 100644
index 0000000..faf52cd
--- /dev/null
+++ b/lib/holidays/lv.rb
@@ -0,0 +1,63 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/lv.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/lv'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module LV # :nodoc:
+ DEFINED_REGIONS = [:lv]
+
+ 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]}],
+ 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]}],
+ 1 => [{:mday => 1, :name => "Jaunais Gads", :regions => [:lv]}],
+ 12 => [{:mday => 25, :name => "Ziemassvetki", :regions => [:lv]},
+ {: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)
diff --git a/lib/holidays/mx.rb b/lib/holidays/mx.rb
new file mode 100644
index 0000000..db9217b
--- /dev/null
+++ b/lib/holidays/mx.rb
@@ -0,0 +1,72 @@
+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
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/mx'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module MX # :nodoc:
+ DEFINED_REGIONS = [:mx, :us, :ca]
+
+ HOLIDAYS_BY_MONTH = {
+ 5 => [{:mday => 1, :name => "D\xC3\xADa del Trabajo", :regions => [:mx]},
+ {:mday => 5, :name => "La Batalla de Puebla", :regions => [:mx]},
+ {:wday => 0, :week => 3, :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]}],
+ 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]},
+ {:mday => 2, :name => "New Year's Day", :regions => [:mx]}],
+ 12 => [{:mday => 12, :name => "Our Lady of Guadalupe's day", :regions => [:mx]},
+ {:mday => 25, :name => "Christmas Day", :regions => [:mx]}],
+ 2 => [{:wday => 1, :week => 1, :name => "D\xC3\xADa de la Constituci\xC3\xB3n", :regions => [:mx]},
+ {:mday => 2, :name => "Groundhog Day", :regions => [:us, :ca]},
+ {:mday => 14, :name => "Valentine's Day", :regions => [:us, :ca]}],
+ 3 => [{:wday => 1, :week => 3, :name => "Natalicio de Benito Ju\xC3\xA1rez", :regions => [:mx]},
+ {:mday => 17, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
+ 9 => [{:mday => 16, :name => "D\xC3\xADa de Independencia", :regions => [:mx]}],
+ 4 => [{:mday => 1, :name => "April Fool's Day", :regions => [:us, :ca]},
+ {:mday => 22, :name => "Earth Day", :regions => [:us, :ca]}],
+ 10 => [{:mday => 31, :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)
diff --git a/lib/holidays/nl.rb b/lib/holidays/nl.rb
new file mode 100644
index 0000000..da624db
--- /dev/null
+++ b/lib/holidays/nl.rb
@@ -0,0 +1,62 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/nl.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/nl'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module NL # :nodoc:
+ DEFINED_REGIONS = [:nl]
+
+ 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, :nl]},
+ {:function => lambda { |year| easter(year)+40 }, :name => "Hemelvaartsdag", :regions => [:nl]},
+ {:function => lambda { |year| easter(year)+49 }, :name => "Pinksteren", :regions => [:nl, :nl]}],
+ 1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]}],
+ 12 => [{:mday => 5, :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)
diff --git a/lib/holidays/north_america.rb b/lib/holidays/north_america.rb
index e3cfe2e..4def2e3 100644
--- a/lib/holidays/north_america.rb
+++ b/lib/holidays/north_america.rb
@@ -1,137 +1,120 @@
-module Holidays
- # This file is generated by the Ruby Holiday gem.
- #
- # Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/common_methods.yaml, data/north_america_informal.yaml
- #
- # To use the definitions in the file, load them right after you load the
- # Holiday gem:
- #
- # require 'holidays'
- # require 'path/to/northamerica'
- #
- # More definitions are available at http://code.dunae.ca/holidays.
- module NorthAmerica # :nodoc:
- DEFINED_REGIONS = [:ca, :ca_qc, :mx, :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]},
- {: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]},
- {:wday => 0, :week => 3, :name => "Father's Day", :regions => [:us, :ca]}],
- 0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:ca, :mx, :us]},
- {: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]}],
- 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]},
- {:mday => 11, :name => "Veterans Day", :regions => [:us]},
- {:wday => 4, :week => 4, :name => "Thanksgiving Day", :regions => [:us]}],
- 6 => [{:mday => 24, :name => "Discovery Day", :regions => [:ca_nf]},
- {:mday => 24, :name => "Fête Nationale", :regions => [:ca_qc]},
- {:mday => 21, :name => "National Aboriginal Day", :regions => [:ca_nt]}],
- 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca, :mx, :us]},
- {: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]}],
- 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]}],
- 7 => [{:mday => 1, :name => "Canada Day", :regions => [:ca]},
- {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
- {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]},
- {:mday => 4, :name => "Independence Day", :regions => [:us]}],
- 2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
- {:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
- {:wday => 1, :week => 1, :name => "D\xC3\xADa de la Constituci\xC3\xB3n", :regions => [:mx]},
- {:mday => 2, :name => "Groundhog Day", :regions => [:us, :ca]},
- {:mday => 14, :name => "Valentine's Day", :regions => [:us, :ca]}],
- 8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
- {:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
- {:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
- {:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
- {:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
- {:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
- 3 => [{:mday => 23, :name => "St. George's Day", :regions => [:ca_nf]},
- {:wday => 1, :week => 3, :name => "Natalicio de Benito Ju\xC3\xA1rez", :regions => [:mx]},
- {:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
- {:mday => 17, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
- 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]},
- {:mday => 16, :name => "D\xC3\xADa de Independencia", :regions => [:mx]},
- {:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
- 4 => [{:mday => 1, :name => "April Fool's Day", :regions => [:us, :ca]},
- {:mday => 22, :name => "Earth Day", :regions => [:us, :ca]}],
- 10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
- {:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
- {:mday => 31, :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
-
-
-# Monday on or before May 24
-def self.ca_victoria_day(year)
- date = Date.civil(year,5,24)
- if date.wday > 1
- date -= (date.wday - 1)
- elsif date.wday == 0
- date -= 6
- end
- date
-end
-
-# January 20, every fourth year, following Presidential election
-def self.us_inauguration_day(year)
- year % 4 == 1 ? 20 : nil
-end
-
-
- end
-end
-
-Holidays.class_eval do
- existing_regions = []
- if const_defined?(:DEFINED_REGIONS)
- existing_regions = const_get(:DEFINED_REGIONS)
- remove_const(:DEFINED_REGIONS)
- end
- const_set(:DEFINED_REGIONS, existing_regions | Holidays::NorthAmerica::DEFINED_REGIONS)
-
- existing_defs = {}
- if const_defined?(:HOLIDAYS_BY_MONTH)
- existing_defs = const_get(:HOLIDAYS_BY_MONTH)
- remove_const(:HOLIDAYS_BY_MONTH)
- end
- #const_set(:HOLIDAYS_BY_MONTH, existing_defs.merge(Holidays::NorthAmerica::HOLIDAYS_BY_MONTH))
- const_set(:HOLIDAYS_BY_MONTH, Holidays::NorthAmerica::HOLIDAYS_BY_MONTH)
-
- include Holidays::NorthAmerica
-end
+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
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/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]},
+ {:wday => 0, :week => 3, :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]}],
+ 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]},
+ {:mday => 11, :name => "Veterans Day", :regions => [:us]},
+ {:wday => 4, :week => 4, :name => "Thanksgiving Day", :regions => [:us]}],
+ 6 => [{:mday => 24, :name => "Discovery Day", :regions => [:ca_nf]},
+ {:mday => 24, :name => "Fête Nationale", :regions => [:ca_qc]},
+ {:mday => 21, :name => "National Aboriginal Day", :regions => [:ca_nt]}],
+ 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca, :mx, :us]},
+ {: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]}],
+ 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]}],
+ 7 => [{:mday => 1, :name => "Canada Day", :regions => [:ca]},
+ {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]},
+ {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]},
+ {:mday => 4, :name => "Independence Day", :regions => [:us]}],
+ 2 => [{:wday => 1, :week => 3, :name => "Family Day", :regions => [:ca_ab, :ca_on, :ca_sk]},
+ {:wday => 1, :week => 3, :name => "Louis Riel Day", :regions => [:ca_mb]},
+ {:mday => 2, :name => "Groundhog Day", :regions => [:us, :ca]},
+ {:mday => 14, :name => "Valentine's Day", :regions => [:us, :ca]},
+ {:wday => 1, :week => 1, :name => "D\xC3\xADa de la Constituci\xC3\xB3n", :regions => [:mx]}],
+ 8 => [{:wday => 1, :week => 1, :name => "BC Day", :regions => [:ca_bc]},
+ {:wday => 1, :week => 1, :name => "Saskatchewan Day", :regions => [:ca_sk]},
+ {:wday => 1, :week => 1, :name => "Heritage Day", :regions => [:ca_ab]},
+ {:wday => 1, :week => 1, :name => "Natal Day", :regions => [:ca_ns]},
+ {:wday => 1, :week => 1, :name => "Civic Holiday", :regions => [:ca_on]},
+ {:wday => 1, :week => 3, :name => "Discovery Day", :regions => [:ca_yk]}],
+ 3 => [{:mday => 23, :name => "St. George's Day", :regions => [:ca_nf]},
+ {:mday => 17, :name => "St. Patrick's Day", :regions => [:us, :ca]},
+ {:wday => 1, :week => 3, :name => "Natalicio de Benito Ju\xC3\xA1rez", :regions => [:mx]},
+ {:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]}],
+ 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]},
+ {:mday => 16, :name => "D\xC3\xADa de Independencia", :regions => [:mx]},
+ {:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
+ 4 => [{:mday => 1, :name => "April Fool's Day", :regions => [:us, :ca]},
+ {:mday => 22, :name => "Earth Day", :regions => [:us, :ca]}],
+ 10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
+ {:mday => 31, :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
+
+
+# Monday on or before May 24
+def self.ca_victoria_day(year)
+ date = Date.civil(year,5,24)
+ if date.wday > 1
+ date -= (date.wday - 1)
+ elsif date.wday == 0
+ date -= 6
+ end
+ date
+end
+
+# January 20, every fourth year, following Presidential election
+def self.us_inauguration_day(year)
+ year % 4 == 1 ? 20 : nil
+end
+
+
+ end
+end
+
+Holidays.merge_defs(Holidays::NORTH_AMERICA::DEFINED_REGIONS, Holidays::NORTH_AMERICA::HOLIDAYS_BY_MONTH)
diff --git a/lib/holidays/united_nations.rb b/lib/holidays/united_nations.rb
new file mode 100644
index 0000000..ef4af07
--- /dev/null
+++ b/lib/holidays/united_nations.rb
@@ -0,0 +1,24 @@
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/united_nations.yaml
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/united_nations'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module UNITED_NATIONS # :nodoc:
+ DEFINED_REGIONS = [:]
+
+ HOLIDAYS_BY_MONTH = {
+
+ }
+
+
+ end
+end
+
+Holidays.merge_defs(Holidays::UNITED_NATIONS::DEFINED_REGIONS, Holidays::UNITED_NATIONS::HOLIDAYS_BY_MONTH)
diff --git a/lib/holidays/us.rb b/lib/holidays/us.rb
new file mode 100644
index 0000000..a0ff0fb
--- /dev/null
+++ b/lib/holidays/us.rb
@@ -0,0 +1,75 @@
+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
+ #
+ # To use the definitions in the file, load them right after you load the
+ # Holiday gem:
+ #
+ # require 'holidays'
+ # require 'path/to/us'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module US # :nodoc:
+ DEFINED_REGIONS = [:us, :ca]
+
+ HOLIDAYS_BY_MONTH = {
+ 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
+ {:wday => 0, :week => 3, :name => "Father's Day", :regions => [:us, :ca]}],
+ 0 => [{:function => lambda { |year| easter(year)-2 }, :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]}],
+ 12 => [{:mday => 25, :name => "Christmas Day", :regions => [:us]}],
+ 7 => [{:mday => 4, :name => "Independence Day", :regions => [:us]}],
+ 2 => [{:mday => 2, :name => "Groundhog Day", :regions => [:us, :ca]},
+ {:mday => 14, :name => "Valentine's Day", :regions => [:us, :ca]}],
+ 3 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
+ {:mday => 17, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
+ 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
+ 4 => [{:mday => 1, :name => "April Fool's Day", :regions => [:us, :ca]},
+ {:mday => 22, :name => "Earth Day", :regions => [:us, :ca]}],
+ 10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
+ {:mday => 31, :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
+
+
+# January 20, every fourth year, following Presidential election
+def self.us_inauguration_day(year)
+ year % 4 == 1 ? 20 : nil
+end
+
+
+ end
+end
+
+Holidays.merge_defs(Holidays::US::DEFINED_REGIONS, Holidays::US::HOLIDAYS_BY_MONTH)
diff --git a/lib/holidays/za.rb b/lib/holidays/za.rb
index b27a328..2aa08a6 100644
--- a/lib/holidays/za.rb
+++ b/lib/holidays/za.rb
@@ -1,80 +1,63 @@
-module Holidays
- # This file is generated by the Ruby Holiday gem.
- #
- # Definitions loaded: data/za.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/za'
- #
- # More definitions are available at http://code.dunae.ca/holidays.
- module ZA # :nodoc:
- DEFINED_REGIONS = [:za]
-
- 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]}],
- 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]},
- {:mday => 25, :name => "Christmas Day", :regions => [:za]},
- {:mday => 26, :name => "Day of Goodwill", :regions => [:za]}],
- 8 => [{:mday => 9, :name => "National Women's Day", :regions => [:za]}],
- 3 => [{:mday => 21, :name => "Human Rights Day", :regions => [:za]}],
- 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.class_eval do
- existing_regions = []
- if const_defined?(:DEFINED_REGIONS)
- existing_regions = const_get(:DEFINED_REGIONS)
- remove_const(:DEFINED_REGIONS)
- end
- const_set(:DEFINED_REGIONS, existing_regions | Holidays::ZA::DEFINED_REGIONS)
-
- existing_defs = {}
- if const_defined?(:HOLIDAYS_BY_MONTH)
- existing_defs = const_get(:HOLIDAYS_BY_MONTH)
- remove_const(:HOLIDAYS_BY_MONTH)
- end
- #const_set(:HOLIDAYS_BY_MONTH, existing_defs.merge(Holidays::ZA::HOLIDAYS_BY_MONTH))
- const_set(:HOLIDAYS_BY_MONTH, Holidays::ZA::HOLIDAYS_BY_MONTH)
-
- include Holidays::ZA
-end
+module Holidays
+ # This file is generated by the Ruby Holiday gem.
+ #
+ # Definitions loaded: data/za.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/za'
+ #
+ # More definitions are available at http://code.dunae.ca/holidays.
+ module ZA # :nodoc:
+ DEFINED_REGIONS = [:za]
+
+ 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]}],
+ 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]},
+ {:mday => 25, :name => "Christmas Day", :regions => [:za]},
+ {:mday => 26, :name => "Day of Goodwill", :regions => [:za]}],
+ 8 => [{:mday => 9, :name => "National Women's Day", :regions => [:za]}],
+ 3 => [{:mday => 21, :name => "Human Rights Day", :regions => [:za]}],
+ 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)
diff --git a/rakefile.rb b/rakefile.rb
index 890e6d0..112c9bb 100644
--- a/rakefile.rb
+++ b/rakefile.rb
@@ -4,7 +4,31 @@ require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'fileutils'
require 'lib/holidays'
-require 'csv'
+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'],
+ :united_nations => ['data/united_nations.yaml'],
+ :za => ['data/za.yaml', 'data/common_methods.yaml']
+ }
+
+def_list[:north_america] = def_list[:ca] | def_list[:mx] | def_list[:us]
+
+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]
+
desc 'Run the unit tests.'
Rake::TestTask.new do |t|
@@ -14,9 +38,43 @@ Rake::TestTask.new do |t|
t.verbose = false
end
-task :build_defs do
- puts ARGV
- puts ARGV[1]
+namespace 'definitions' do
+ task :build_all do
+ def_list.each do |region, files|
+ puts "Building #{region.to_s.upcase} definition module:"
+ files.uniq!
+ parsed = parse_holiday_defs(region.to_s.upcase, files)
+ File.open("lib/holidays/#{region.to_s}.rb","w") do |file|
+ file.puts parsed
+ end
+ puts "Done.\n\n"
+ end
+ end
+end
+
+
+task :manifest do
+ File.open("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
@@ -26,14 +84,13 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.title = 'Ruby Holidays Gem'
rdoc.options << '--all' << '--inline-source' << '--line-numbers'
rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('MANIFEST')
rdoc.rdoc_files.include('CUSTOM DATES')
rdoc.rdoc_files.include('REFERENCES')
rdoc.rdoc_files.include('LICENSE')
rdoc.rdoc_files.include('lib/*.rb')
- rdoc.rdoc_files.include('lib/holidays/*.rb')
end
-
spec = Gem::Specification.new do |s|
s.name = 'holidays'
s.version = '0.9.0'
diff --git a/test/benchmark.rb b/test/benchmark.rb
index c9abfcd..163ed00 100644
--- a/test/benchmark.rb
+++ b/test/benchmark.rb
@@ -1,19 +1,45 @@
require File.dirname(__FILE__) + '/test_helper'
require 'date'
+require 'holidays'
+require 'holidays/ca'
require 'benchmark'
-n = 10000
-Benchmark.bm do |x|
- x.report('calculate_mday') do
- n.times do
- Holidays.calculate_mday(2008, 1, 1, 3)
+n = 10000
+dt = Date.civil(2035,3,23)
+Benchmark.bm do |x|
+
+ x.report('0001') do
+ 1.times do
+ r = Holidays.on(dt, :any)
end
end
- x.report('calculate_mdaya') do
- n.times do
- Holidays.calculate_mdaya(:third, 1, 1, 2008)
+
+
+ x.report('0010') do
+ 10.times do
+ r = Holidays.on(dt, :any)
end
end
+
+ x.report('0100') do
+ 100.times do
+ r = Holidays.on(dt, :any)
+ end
+ end
+
+ x.report('1000') do
+ 1000.times do
+ r = Holidays.on(dt, :any)
+ end
+ end
+
+
+ x.report('5000') do
+ 5000.times do
+ r = Holidays.on(dt, :any)
+ end
+ end
+
end
\ No newline at end of file
diff --git a/test/test_holidays.rb b/test/test_holidays.rb
index 1cb1006..310b0f3 100644
--- a/test/test_holidays.rb
+++ b/test/test_holidays.rb
@@ -25,8 +25,6 @@ class HolidaysTests < Test::Unit::TestCase
assert_equal 0, holidays.length
end
-
-
def test_requires_valid_regions
assert_raises Holidays::UnkownRegionError do
Holidays.on(Date.civil(2008,1,1), :xx)