Updates to definition build process
This commit is contained in:
parent
4a99b463fa
commit
8f3f04d2b2
13 changed files with 169 additions and 581 deletions
|
@ -132,7 +132,7 @@ EOM
|
|||
# Build the test file
|
||||
unless test_strs.empty?
|
||||
test_src =<<-EndOfTests
|
||||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
require 'holidays/#{module_name.downcase}'
|
||||
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
|
@ -150,5 +150,3 @@ end
|
|||
return module_src, test_src || ''
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
21
data/index.yaml
Normal file
21
data/index.yaml
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Definition build list
|
||||
---
|
||||
defs:
|
||||
AU: ['au.yaml']
|
||||
CA: ['ca.yaml', 'north_america_informal.yaml']
|
||||
DK: ['dk.yaml']
|
||||
DE: ['de.yaml']
|
||||
ES: ['es.yaml']
|
||||
FR: ['fr.yaml']
|
||||
GB: ['gb.yaml']
|
||||
IE: ['ie.yaml']
|
||||
IS: ['is.yaml']
|
||||
IT: ['it.yaml']
|
||||
MX: ['mx.yaml', 'north_america_informal.yaml']
|
||||
NL: ['nl.yaml']
|
||||
PT: ['se.yaml']
|
||||
US: ['au.yaml', 'north_america_informal.yaml']
|
||||
United_Nations: ['united_nations.yaml']
|
||||
ZA: ['za.yaml']
|
||||
North_America: ['ca.yaml', 'mx.yaml', 'us.yaml', 'north_america_informal.yaml']
|
||||
Europe: ['dk.yaml', 'de.yaml', 'es.yaml', 'fr.yaml', 'gb.yaml', 'ie.yaml', 'is.yaml', 'it.yaml', 'nl.yaml', 'pt.yaml']
|
|
@ -1,6 +1,5 @@
|
|||
==== Regional definitions
|
||||
The following definition files are included in the default
|
||||
installation:
|
||||
The following definition files are included in this installation:
|
||||
|
||||
* holidays/au
|
||||
* holidays/ca
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/dk.yaml, data/de.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/nl.yaml, data/pt.yaml, data/se.yaml
|
||||
# Definitions loaded: data/dk.yaml, data/de.yaml, data/es.yaml, data/fr.yaml, data/gb.yaml, data/ie.yaml, data/is.yaml, data/it.yaml, data/nl.yaml, data/pt.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
|
@ -10,8 +10,8 @@ module Holidays
|
|||
# require 'holidays/europe'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module EUROPE # :nodoc:
|
||||
DEFINED_REGIONS = [:dk, :de, :fr, :de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_sn, :de_he, :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, :is, :it, :nl, :pt, :se]
|
||||
module Europe # :nodoc:
|
||||
DEFINED_REGIONS = [:dk, :de, :fr, :de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_sn, :de_he, :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, :is, :it, :nl, :pt]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]},
|
||||
|
@ -31,8 +31,7 @@ module Holidays
|
|||
{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]},
|
||||
{:mday => 4, :name => "Dodenherdenking", :regions => [:nl]},
|
||||
{:mday => 5, :name => "Bevrijdingsdag", :regions => [:nl]},
|
||||
{:mday => 1, :name => "Dia do Trabalhador", :regions => [:pt]},
|
||||
{:mday => 1, :name => "Första maj", :regions => [:se]}],
|
||||
{:mday => 1, :name => "Dia do Trabalhador", :regions => [:pt]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-49 }, :function_id => "easter(year)-49", :type => :informal, :name => "Fastelavn", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Palmesøndag", :regions => [:dk]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skærtorsdag", :regions => [:dk]},
|
||||
|
@ -82,13 +81,7 @@ module Holidays
|
|||
{:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :type => :informal, :name => "Carnaval", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Sexta-feira Santa", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páscoa", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Corpo de Deus", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Långfredagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskdagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annandag påsk", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi himmelsfärdsdag", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pingstdagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.se_alla_helgons_dag(year) }, :function_id => "se_alla_helgons_dag(year)", :name => "Alla helgons dag", :regions => [:se]}],
|
||||
{:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Corpo de Deus", :regions => [:pt]}],
|
||||
11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]},
|
||||
{:mday => 1, :name => "Allerheiligen", :regions => [:de_bw, :de_by, :de_nw, :de_rp, :de_sl]},
|
||||
{:function => lambda { |year| Holidays.de_buss_und_bettag(year) }, :function_id => "de_buss_und_bettag(year)", :name => "Buß- und Bettag", :regions => [:de_by, :de_sn]},
|
||||
|
@ -108,9 +101,7 @@ module Holidays
|
|||
{:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]},
|
||||
{:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]},
|
||||
{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]},
|
||||
{:mday => 10, :name => "Dia de Portugal", :regions => [:pt]},
|
||||
{:mday => 6, :name => "Nationaldagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.se_midsommardagen(year) }, :function_id => "se_midsommardagen(year)", :name => "Midsommardagen", :regions => [:se]}],
|
||||
{:mday => 10, :name => "Dia de Portugal", :regions => [:pt]}],
|
||||
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]},
|
||||
|
@ -125,9 +116,7 @@ module Holidays
|
|||
{:mday => 1, :name => "Capodanno", :regions => [:it]},
|
||||
{:mday => 6, :name => "Epifania", :regions => [:it]},
|
||||
{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]},
|
||||
{:mday => 1, :name => "Ano Novo", :regions => [:pt]},
|
||||
{:mday => 1, :name => "Nyårsdagen", :regions => [:se]},
|
||||
{:mday => 6, :name => "Trettondedag jul", :regions => [:se]}],
|
||||
{:mday => 1, :name => "Ano Novo", :regions => [:pt]}],
|
||||
12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]},
|
||||
{:mday => 24, :name => "Juleaftensdag", :regions => [:dk]},
|
||||
{:mday => 25, :name => "1. juledag", :regions => [:dk]},
|
||||
|
@ -155,9 +144,7 @@ module Holidays
|
|||
{:mday => 26, :name => "Kerstmis", :regions => [:nl]},
|
||||
{:mday => 1, :name => "Restauração da Independência", :regions => [:pt]},
|
||||
{:mday => 8, :name => "Imaculada Conceição", :regions => [:pt]},
|
||||
{:mday => 25, :name => "Natal", :regions => [:pt]},
|
||||
{:mday => 25, :name => "Juldagen", :regions => [:se]},
|
||||
{:mday => 26, :name => "Annandag jul", :regions => [:se]}],
|
||||
{:mday => 25, :name => "Natal", :regions => [:pt]}],
|
||||
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]},
|
||||
|
@ -222,23 +209,7 @@ def self.is_sumardagurinn_fyrsti(year)
|
|||
end
|
||||
|
||||
|
||||
# Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
|
||||
def self.se_alla_helgons_dag(year)
|
||||
date = Date.civil(year,10,31)
|
||||
date += (6 - date.wday)
|
||||
date
|
||||
end
|
||||
|
||||
|
||||
# Sweden: Mid-summer (Saturday between June 20–26)
|
||||
def self.se_midsommardagen(year)
|
||||
date = Date.civil(year,6,20)
|
||||
date += (6 - date.wday)
|
||||
date
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::EUROPE::DEFINED_REGIONS, Holidays::EUROPE::HOLIDAYS_BY_MONTH)
|
||||
Holidays.merge_defs(Holidays::Europe::DEFINED_REGIONS, Holidays::Europe::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/ca.yaml, data/north_america_informal.yaml, data/mx.yaml, data/us.yaml
|
||||
# Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/north_america_informal.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
|
@ -10,19 +10,19 @@ module Holidays
|
|||
# require 'holidays/north_america'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module NORTH_AMERICA # :nodoc:
|
||||
DEFINED_REGIONS = [:ca, :ca_qc, :ca_nf, :ca_nt, :ca_nu, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_bc, :ca_ns, :ca_yk, :us, :mx, :mx_pue, :us_dc]
|
||||
module North_America # :nodoc:
|
||||
DEFINED_REGIONS = [:ca, :ca_qc, :ca_nf, :ca_nt, :ca_nu, :ca_ab, :ca_on, :ca_sk, :ca_mb, :ca_bc, :ca_ns, :ca_yk, :mx, :mx_pue, :us, :us_dc]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :function_id => "ca_victoria_day(year)", :name => "Victoria Day", :regions => [:ca]},
|
||||
{:function => lambda { |year| Holidays.ca_victoria_day(year) }, :function_id => "ca_victoria_day(year)", :name => "National Patriotes Day", :regions => [:ca_qc]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]},
|
||||
{:mday => 1, :name => "Día del Trabajo", :regions => [:mx]},
|
||||
{:mday => 5, :type => :informal, :name => "Cinco de Mayo", :regions => [:mx]},
|
||||
{:mday => 5, :name => "La Batalla de Puebla", :regions => [:mx_pue]},
|
||||
{:mday => 10, :type => :informal, :name => "Día de la Madre", :regions => [:mx]},
|
||||
{:mday => 15, :type => :informal, :name => "Día del Maestro", :regions => [:mx]},
|
||||
{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]}],
|
||||
{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:ca]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :type => :informal, :name => "Easter Monday", :regions => [:ca]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Good Friday", :regions => [:us]}],
|
||||
|
@ -56,10 +56,10 @@ module Holidays
|
|||
{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :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, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
||||
{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]},
|
||||
{:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]},
|
||||
{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]}],
|
||||
{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
|
||||
{:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
||||
{:mday => 14, :type => :informal, :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]},
|
||||
|
@ -67,19 +67,19 @@ module Holidays
|
|||
{: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, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]},
|
||||
{:wday => 1, :week => 3, :name => "Natalicio de Benito Juárez", :regions => [:mx]}],
|
||||
{:wday => 1, :week => 3, :name => "Natalicio de Benito Juárez", :regions => [:mx]},
|
||||
{:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
|
||||
9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]},
|
||||
{:mday => 15, :name => "Grito de Dolores", :regions => [:mx]},
|
||||
{:mday => 16, :name => "Día de la Independencia", :regions => [:mx]},
|
||||
{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
|
||||
4 => [{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
|
||||
{:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]},
|
||||
{:mday => 30, :type => :informal, :name => "Día del Niño", :regions => [:mx]}],
|
||||
4 => [{:mday => 30, :type => :informal, :name => "Día del Niño", :regions => [:mx]},
|
||||
{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
|
||||
{:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}],
|
||||
10 => [{:wday => 1, :week => 2, :name => "Thanksgiving", :regions => [:ca]},
|
||||
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]},
|
||||
{:mday => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]},
|
||||
{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]}]
|
||||
{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
|
||||
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -104,4 +104,4 @@ end
|
|||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::NORTH_AMERICA::DEFINED_REGIONS, Holidays::NORTH_AMERICA::HOLIDAYS_BY_MONTH)
|
||||
Holidays.merge_defs(Holidays::North_America::DEFINED_REGIONS, Holidays::North_America::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/pt.yaml
|
||||
# Definitions loaded: data/se.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
|
@ -11,26 +11,41 @@ module Holidays
|
|||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module PT # :nodoc:
|
||||
DEFINED_REGIONS = [:pt]
|
||||
DEFINED_REGIONS = [:se]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:mday => 1, :name => "Dia do Trabalhador", :regions => [:pt]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :type => :informal, :name => "Carnaval", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Sexta-feira Santa", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páscoa", :regions => [:pt]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Corpo de Deus", :regions => [:pt]}],
|
||||
11 => [{:mday => 1, :name => "Todos os Santos", :regions => [:pt]}],
|
||||
6 => [{:mday => 10, :name => "Dia de Portugal", :regions => [:pt]}],
|
||||
1 => [{:mday => 1, :name => "Ano Novo", :regions => [:pt]}],
|
||||
12 => [{:mday => 1, :name => "Restauração da Independência", :regions => [:pt]},
|
||||
{:mday => 8, :name => "Imaculada Conceição", :regions => [:pt]},
|
||||
{:mday => 25, :name => "Natal", :regions => [:pt]}],
|
||||
8 => [{:mday => 15, :name => "Assunção de Nossa Senhora", :regions => [:pt]}],
|
||||
4 => [{:mday => 25, :name => "Dia da Liberdade", :regions => [:pt]}],
|
||||
10 => [{:mday => 5, :name => "Implantação da República", :regions => [:pt]}]
|
||||
5 => [{:mday => 1, :name => "Första maj", :regions => [:se]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Långfredagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskdagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annandag påsk", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi himmelsfärdsdag", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pingstdagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.se_alla_helgons_dag(year) }, :function_id => "se_alla_helgons_dag(year)", :name => "Alla helgons dag", :regions => [:se]}],
|
||||
6 => [{:mday => 6, :name => "Nationaldagen", :regions => [:se]},
|
||||
{:function => lambda { |year| Holidays.se_midsommardagen(year) }, :function_id => "se_midsommardagen(year)", :name => "Midsommardagen", :regions => [:se]}],
|
||||
1 => [{:mday => 1, :name => "Nyårsdagen", :regions => [:se]},
|
||||
{:mday => 6, :name => "Trettondedag jul", :regions => [:se]}],
|
||||
12 => [{:mday => 25, :name => "Juldagen", :regions => [:se]},
|
||||
{:mday => 26, :name => "Annandag jul", :regions => [:se]}]
|
||||
}
|
||||
end
|
||||
|
||||
# Sweden: All Saint's Day (Saturday between Oct 31 and Nov 6)
|
||||
def self.se_alla_helgons_dag(year)
|
||||
date = Date.civil(year,10,31)
|
||||
date += (6 - date.wday)
|
||||
date
|
||||
end
|
||||
|
||||
|
||||
# Sweden: Mid-summer (Saturday between June 20–26)
|
||||
def self.se_midsommardagen(year)
|
||||
date = Date.civil(year,6,20)
|
||||
date += (6 - date.wday)
|
||||
date
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Holidays
|
|||
# require 'holidays/united_nations'
|
||||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module UNITED_NATIONS # :nodoc:
|
||||
module United_Nations # :nodoc:
|
||||
DEFINED_REGIONS = [:]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
|
@ -21,4 +21,4 @@ module Holidays
|
|||
|
||||
end
|
||||
|
||||
Holidays.merge_defs(Holidays::UNITED_NATIONS::DEFINED_REGIONS, Holidays::UNITED_NATIONS::HOLIDAYS_BY_MONTH)
|
||||
Holidays.merge_defs(Holidays::United_Nations::DEFINED_REGIONS, Holidays::United_Nations::HOLIDAYS_BY_MONTH)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Holidays
|
||||
# This file is generated by the Ruby Holiday gem.
|
||||
#
|
||||
# Definitions loaded: data/us.yaml, data/north_america_informal.yaml
|
||||
# Definitions loaded: data/au.yaml, data/north_america_informal.yaml
|
||||
#
|
||||
# To use the definitions in this file, load them right after you load the
|
||||
# Holiday gem:
|
||||
|
@ -11,37 +11,37 @@ module Holidays
|
|||
#
|
||||
# More definitions are available at http://code.dunae.ca/holidays.
|
||||
module US # :nodoc:
|
||||
DEFINED_REGIONS = [:us, :us_dc, :ca]
|
||||
DEFINED_REGIONS = [:au_qld, :au_nt, :au, :au_tas, :au_wa, :au_act, :au_nsw, :au_sa, :au_vic, :us, :ca]
|
||||
|
||||
HOLIDAYS_BY_MONTH = {
|
||||
5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]},
|
||||
5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld]},
|
||||
{:wday => 1, :week => 1, :name => "May Day", :regions => [:au_nt]},
|
||||
{:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}],
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :type => :informal, :name => "Good Friday", :regions => [:us]}],
|
||||
11 => [{:mday => 11, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Veterans Day", :regions => [:us]},
|
||||
{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:us]}],
|
||||
1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:us]},
|
||||
{:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:us]},
|
||||
{:function => lambda { |year| Holidays.us_inauguration_day(year) }, :function_id => "us_inauguration_day(year)", :name => "Inauguration Day", :regions => [:us_dc]}],
|
||||
12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}],
|
||||
7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:us]}],
|
||||
2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:us]},
|
||||
{:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
||||
0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:au]},
|
||||
{:function => lambda { |year| Holidays.easter(year)-1 }, :function_id => "easter(year)-1", :name => "Easter Saturday", :regions => [:au]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:au]},
|
||||
{:function => lambda { |year| Holidays.easter(year)+2 }, :function_id => "easter(year)+2", :name => "Easter Monday", :regions => [:au_tas]}],
|
||||
6 => [{:wday => 1, :week => 1, :name => "Foundation Day", :regions => [:au_wa]},
|
||||
{:wday => 1, :week => 2, :name => "Queen's Birthday", :regions => [:au_act, :au_nsw, :au_sa, :au_tas, :au_nt, :au_qld, :au_vic]},
|
||||
{:mday => 6, :type => :informal, :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]}],
|
||||
2 => [{:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]},
|
||||
{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}],
|
||||
3 => [{:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
|
||||
9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:us]}],
|
||||
4 => [{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
|
||||
3 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_wa]},
|
||||
{:wday => 1, :week => 2, :name => "Eight Hours Day", :regions => [:au_tas]},
|
||||
{:wday => 1, :week => 2, :name => "Labour Day", :regions => [:au_vic]},
|
||||
{:mday => 17, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}],
|
||||
4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]},
|
||||
{:mday => 1, :type => :informal, :name => "April Fool's Day", :regions => [:us, :ca]},
|
||||
{:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}],
|
||||
10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]},
|
||||
10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]},
|
||||
{:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}]
|
||||
}
|
||||
end
|
||||
|
||||
# January 20, every fourth year, following Presidential election
|
||||
def self.us_inauguration_day(year)
|
||||
year % 4 == 1 ? 20 : nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
|
140
rakefile.rb
140
rakefile.rb
|
@ -2,94 +2,31 @@ require 'rake'
|
|||
require 'rake/testtask'
|
||||
require 'rake/rdoctask'
|
||||
require 'rake/gempackagetask'
|
||||
require 'yaml'
|
||||
require 'fileutils'
|
||||
require 'lib/holidays'
|
||||
require 'data/build_defs'
|
||||
|
||||
def_list = {
|
||||
:au => ['data/au.yaml'],
|
||||
:ca => ['data/ca.yaml', 'data/north_america_informal.yaml'],
|
||||
:dk => ['data/dk.yaml'],
|
||||
:de => ['data/de.yaml'],
|
||||
:es => ['data/es.yaml'],
|
||||
:fr => ['data/fr.yaml'],
|
||||
:gb => ['data/gb.yaml'],
|
||||
:ie => ['data/ie.yaml'],
|
||||
:is => ['data/is.yaml'],
|
||||
:it => ['data/it.yaml'],
|
||||
:mx => ['data/mx.yaml', 'data/north_america_informal.yaml'],
|
||||
:nl => ['data/nl.yaml'],
|
||||
:pt => ['data/pt.yaml'],
|
||||
:se => ['data/se.yaml'],
|
||||
:us => ['data/us.yaml', 'data/north_america_informal.yaml'],
|
||||
:united_nations => ['data/united_nations.yaml'],
|
||||
:za => ['data/za.yaml']
|
||||
}
|
||||
desc 'Run all tests'
|
||||
task :test => ["test:lib", "test:defs"]
|
||||
|
||||
def_list[:north_america] = []
|
||||
[:ca, :mx, :us].each do |r|
|
||||
def_list[:north_america] += def_list[r]
|
||||
end
|
||||
def_list[:north_america].uniq!
|
||||
|
||||
def_list[:scandinavia] = []
|
||||
[:dk, :is, :se].each do |r|
|
||||
def_list[:scandinavia] += def_list[r]
|
||||
end
|
||||
def_list[:scandinavia].uniq!
|
||||
|
||||
def_list[:europe] = []
|
||||
[:dk, :de, :es, :fr, :gb, :ie, :is, :it, :nl, :pt, :se].each do |r|
|
||||
def_list[:europe] += def_list[r]
|
||||
end
|
||||
def_list[:europe].uniq!
|
||||
|
||||
|
||||
desc 'Run the unit tests.'
|
||||
Rake::TestTask.new do |t|
|
||||
namespace :test do
|
||||
desc 'Run the unit tests.'
|
||||
Rake::TestTask.new(:lib) do |t|
|
||||
t.libs << 'lib'
|
||||
t.test_files = FileList['test/defs/test*.rb'].exclude('test_helper.rb')
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
desc 'Run the definition tests.'
|
||||
Rake::TestTask.new(:defs) do |t|
|
||||
t.libs << 'lib'
|
||||
t.libs << 'lib/test'
|
||||
t.test_files = FileList['test/test*.rb'].exclude('test_helper.rb')
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
namespace 'definitions' do
|
||||
desc 'Build holiday definition files'
|
||||
task :build_all do
|
||||
def_list.each do |region, files|
|
||||
puts "Building #{region.to_s.upcase} definition module:"
|
||||
files.uniq!
|
||||
module_src, test_src = parse_holiday_defs(region.to_s.upcase, files)
|
||||
File.open("lib/holidays/#{region.to_s}.rb","w") do |file|
|
||||
file.puts module_src
|
||||
end
|
||||
unless test_src.empty?
|
||||
File.open("test/test_defs_#{region.to_s}.rb","w") do |file|
|
||||
file.puts test_src
|
||||
end
|
||||
end
|
||||
puts "Done.\n\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
task :doc => [:manifest, :rdoc]
|
||||
|
||||
desc 'Build the definition manifest.'
|
||||
task :manifest do
|
||||
File.open("lib/holidays/MANIFEST","w") do |file|
|
||||
file.puts <<-EOH
|
||||
==== Regional definitions
|
||||
The following definition files are included in the default
|
||||
installation:
|
||||
|
||||
EOH
|
||||
FileList.new('lib/holidays/*.rb').each do |str|
|
||||
file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
|
||||
end
|
||||
end
|
||||
end
|
||||
task :doc => ["defs:manifest", :rdoc]
|
||||
|
||||
desc 'Generate documentation.'
|
||||
Rake::RDocTask.new(:rdoc) do |rdoc|
|
||||
|
@ -97,8 +34,8 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|||
rdoc.title = 'Ruby Holidays Gem'
|
||||
rdoc.options << '--all' << '--inline-source' << '--line-numbers'
|
||||
rdoc.options << '--charset' << 'utf-8'
|
||||
rdoc.template = 'extras/rdoc_template.rb'
|
||||
#rdoc.rdoc_files.include('README')
|
||||
#rdoc.template = 'extras/rdoc_template.rb'
|
||||
rdoc.rdoc_files.include('README')
|
||||
rdoc.rdoc_files.include('data/SYNTAX')
|
||||
rdoc.rdoc_files.include('lib/holidays/MANIFEST')
|
||||
rdoc.rdoc_files.include('REFERENCES')
|
||||
|
@ -131,3 +68,48 @@ Rake::GemPackageTask.new(spec) do |pkg|
|
|||
pkg.need_zip = true
|
||||
pkg.need_tar = true
|
||||
end
|
||||
|
||||
desc 'Definition file tasks'
|
||||
namespace :defs do
|
||||
DATA_PATH = 'data'
|
||||
|
||||
desc 'Build holiday definition files'
|
||||
task :build_all do
|
||||
# load the index
|
||||
def_index = YAML.load_file("#{DATA_PATH}/index.yaml")
|
||||
|
||||
# create a dir for the generated tests
|
||||
FileUtils.mkdir_p('test/defs')
|
||||
|
||||
def_index['defs'].each do |region, files|
|
||||
puts "Building #{region} definition module:"
|
||||
files = files.collect { |f| "#{DATA_PATH}/#{f}" }
|
||||
files.uniq!
|
||||
|
||||
module_src, test_src = parse_holiday_defs(region, files)
|
||||
File.open("lib/holidays/#{region.to_s}.rb","w") do |file|
|
||||
file.puts module_src
|
||||
end
|
||||
unless test_src.empty?
|
||||
File.open("test/defs/test_defs_#{region.to_s}.rb","w") do |file|
|
||||
file.puts test_src
|
||||
end
|
||||
end
|
||||
puts "Done.\n\n"
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Build the definition manifest.'
|
||||
task :manifest do
|
||||
File.open("lib/holidays/MANIFEST","w") do |file|
|
||||
file.puts <<-EOH
|
||||
==== Regional definitions
|
||||
The following definition files are included in this installation:
|
||||
|
||||
EOH
|
||||
FileList.new('lib/holidays/*.rb').each do |str|
|
||||
file.puts('* ' + str.gsub(/^lib\/|\.rb$/, ''))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,32 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'holidays/au'
|
||||
|
||||
class AUTests < Test::Unit::TestCase
|
||||
def test_au
|
||||
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2007,1,26) => 'Australia Day',
|
||||
Date.civil(2007,4,6) => 'Good Friday',
|
||||
Date.civil(2007,4,9) => 'Easter Monday',
|
||||
Date.civil(2007,4,25) => 'ANZAC Day',
|
||||
Date.civil(2007,12,25) => 'Christmas Day',
|
||||
Date.civil(2007,12,26) => 'Boxing Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :au, :informal)[0][:name]
|
||||
end
|
||||
|
||||
[:au_sa, :au_act, :au_nsw, :au_].each do |r|
|
||||
assert_equal 'Labour Day', Date.civil(2007,10,1).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:au_sa, :au_act, :au_nsw, :au_vic, :au_tas, :au_qld, :au_nt, :au_].each do |r|
|
||||
assert_equal 'Queen\'s Birthday', Date.civil(2007,6,11).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
assert_equal 'Labour Day', Date.civil(2007,3,5).holidays(:au_wa)[0][:name]
|
||||
assert_equal 'Labour Day', Date.civil(2007,3,12).holidays(:au_vic)[0][:name]
|
||||
assert_equal 'Labour Day', Date.civil(2007,5,7).holidays(:au_qld)[0][:name]
|
||||
|
||||
assert_equal 'May Day', Date.civil(2007,5,7).holidays(:au_nt)[0][:name]
|
||||
|
||||
assert_equal 'Eight Hours Day', Date.civil(2007,3,12).holidays(:au_tas)[0][:name]
|
||||
end
|
||||
end
|
|
@ -1,285 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'holidays/europe'
|
||||
|
||||
class EuropeTests < Test::Unit::TestCase
|
||||
def test_de
|
||||
{Date.civil(2009,1,1) => 'Neujahrstag',
|
||||
Date.civil(2009,4,10) => 'Karfreitag',
|
||||
Date.civil(2009,4,12) => 'Ostern',
|
||||
Date.civil(2009,4,13) => 'Ostermontag',
|
||||
Date.civil(2009,5,1) => 'Tag der Arbeit',
|
||||
Date.civil(2009,5,21) => 'Christi Himmelfahrt',
|
||||
Date.civil(2009,6,1) => 'Pfingstmontag',
|
||||
Date.civil(2009,10,3) => 'Tag der Deutschen Einheit',
|
||||
Date.civil(2009,12,25) => '1. Weihnachtstag',
|
||||
Date.civil(2009,12,26) => '2. Weihnachtstag'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :de, :informal)[0][:name]
|
||||
end
|
||||
|
||||
[:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th, :de_].each do |r|
|
||||
assert_equal 'Fronleichnam', Date.civil(2009,6,11).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:de_by, :de_sl, :de_].each do |r|
|
||||
assert_equal 'Mariä Himmelfahrt', Date.civil(2009,8,15).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:de_bb, :de_mv, :de_sn, :de_st, :de_th, :de_].each do |r|
|
||||
assert_equal 'Reformationstag', Date.civil(2009,10,31).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:de_bw, :de_by, :de_nw, :de_rp, :de_sl, :de_].each do |r|
|
||||
assert_equal 'Allerheiligen', Date.civil(2009,11,1).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
# Repentance Day
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2004,11,17).holidays(:de_sn)[0][:name]
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2005,11,16).holidays(:de_sn)[0][:name]
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2006,11,22).holidays(:de_sn)[0][:name]
|
||||
assert_equal 'Buß- und Bettag', Date.civil(2009,11,18).holidays(:de_sn)[0][:name]
|
||||
end
|
||||
|
||||
def test_dk
|
||||
{Date.civil(2007,1,1) => 'Nytårsdag',
|
||||
Date.civil(2007,2,18) => 'Fastelavn',
|
||||
Date.civil(2007,4,9) => 'Danmarks besættelse',
|
||||
Date.civil(2007,4,16) => 'Dronningens fødselsdag',
|
||||
Date.civil(2007,4,5) => 'Skærtorsdag',
|
||||
Date.civil(2007,4,6) => 'Langfredag',
|
||||
Date.civil(2007,4,8) => 'Påskedag',
|
||||
Date.civil(2007,4,9) => '2. påskedag',
|
||||
Date.civil(2007,5,1) => 'Arbejdernes kampdag',
|
||||
Date.civil(2007,5,4) => 'Store Bededag',
|
||||
Date.civil(2007,5,17) => 'Kristi Himmelfartsdag',
|
||||
Date.civil(2007,5,27) => 'Pinsedag',
|
||||
Date.civil(2007,5,28) => '2. Pinsedag',
|
||||
Date.civil(2007,6,5) => 'Grundlovsdag',
|
||||
Date.civil(2007,12,24) => 'Juleaftensdag',
|
||||
Date.civil(2007,12,25) => '1. juledag',
|
||||
Date.civil(2007,12,26) => '2. juledag'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :dk, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
def test_es
|
||||
{Date.civil(2009,1,1) => 'Año Nuevo',
|
||||
Date.civil(2009,1,6) => 'Día de Reyes',
|
||||
Date.civil(2009,4,10) => 'Viernes Santo',
|
||||
Date.civil(2009,5,1) => 'Día del Trabajador',
|
||||
Date.civil(2009,8,15) => 'Asunción',
|
||||
Date.civil(2009,10,12) => 'Día de la Hispanidad',
|
||||
Date.civil(2009,11,1) => 'Todos los Santos',
|
||||
Date.civil(2009,12,6) => 'Día de la Constitución',
|
||||
Date.civil(2009,12,8) => 'Inmaculada Concepción',
|
||||
Date.civil(2009,12,25) => 'Navidad del Señor'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :es, :informal)[0][:name]
|
||||
end
|
||||
|
||||
[:es_pv, :es_ct, :es_na, :es_v, :es_vc, :es_].each do |r|
|
||||
assert_equal 'Jueves Santo', Date.civil(2009,4,9).holidays(r)[0][:name]
|
||||
assert_equal 'Lunes de Pascua', Date.civil(2009,4,13).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_v, :es_vc, :es_cm, :es_mu, :es_m, :es_].each do |r|
|
||||
assert_equal 'San José', Date.civil(2009,3,19).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_ar, :es_cl, :es_].each do |r|
|
||||
assert_equal 'San Jorge', Date.civil(2009,4,23).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_vc, :es_v, :es_].each do |r|
|
||||
assert_equal 'Día de Valencia', Date.civil(2009,10,9).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
[:es_ib, :es_ct, :es_].each do |r|
|
||||
assert_equal 'San Esteban', Date.civil(2009,12,26).holidays(r)[0][:name]
|
||||
end
|
||||
|
||||
assert_equal 'Día de Andalucía', Date.civil(2009,2,28).holidays(:es_an)[0][:name]
|
||||
assert_equal 'Día de las Islas Baleares', Date.civil(2009,3,1).holidays(:es_ib)[0][:name]
|
||||
assert_equal 'Fiesta de la Comunidad', Date.civil(2006,5,2).holidays(:es_m)[0][:name]
|
||||
assert_equal 'Día de las Canarias', Date.civil(2006,5,30).holidays(:es_cn)[0][:name]
|
||||
assert_equal 'Día de la Región Castilla-La Mancha', Date.civil(2009,5,31).holidays(:es_cm)[0][:name]
|
||||
assert_equal 'Día de la Región de Murcia', Date.civil(2009,6,9).holidays(:es_mu)[0][:name]
|
||||
assert_equal 'Día de La Rioja', Date.civil(2009,6,9).holidays(:es_lo)[0][:name]
|
||||
assert_equal 'Santiago Apostol', Date.civil(2009,7,23).holidays(:es_ga)[0][:name]
|
||||
assert_equal 'Día de Ceuta', Date.civil(2009,9,2).holidays(:es_ce)[0][:name]
|
||||
assert_equal 'Día de Asturias', Date.civil(2009,9,8).holidays(:es_o)[0][:name]
|
||||
assert_equal 'Día de Extremadura', Date.civil(2009,9,8).holidays(:es_ex)[0][:name]
|
||||
assert_equal 'Fiesta Nacional de Cataluña', Date.civil(2009,9,11).holidays(:es_ct)[0][:name]
|
||||
end
|
||||
|
||||
def test_fr
|
||||
{Date.civil(2007,1,1) => 'Jour de l\'an',
|
||||
Date.civil(2007,4,8) => 'Pâques',
|
||||
Date.civil(2007,4,9) => 'Lundi de Pâques',
|
||||
Date.civil(2007,5,1) => 'Fête du travail',
|
||||
Date.civil(2007,5,8) => 'Victoire 1945',
|
||||
Date.civil(2007,5,17) => 'Ascension',
|
||||
Date.civil(2007,5,27) => 'Pentecôte',
|
||||
Date.civil(2007,5,28) => 'Lundi de Pentecôte',
|
||||
Date.civil(2007,7,14) => 'Fête nationale',
|
||||
Date.civil(2007,8,15) => 'Assomption',
|
||||
Date.civil(2007,11,1) => 'Toussaint',
|
||||
Date.civil(2007,11,11) => 'Armistice 1918',
|
||||
Date.civil(2007,12,25) => 'Nöel'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :fr, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_gb
|
||||
# Holidays.between(Date.civil(2010,12,1),Date.civil(2008,12,31),:gb_).each do |h|
|
||||
# puts "#{h[:name]} on #{h[:date]}"
|
||||
# end
|
||||
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,3,21) => 'Good Friday',
|
||||
Date.civil(2008,3,23) => 'Easter Sunday',
|
||||
Date.civil(2008,5,5) => 'May Day',
|
||||
Date.civil(2008,5,26) => 'Bank Holiday',
|
||||
Date.civil(2008,11,5) => 'Guy Fawkes Day',
|
||||
Date.civil(2008,12,25) => 'Christmas Day',
|
||||
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :gb, :informal)[0][:name]
|
||||
end
|
||||
|
||||
assert_equal 'St. Patrick\'s Day', Date.civil(2008,3,17).holidays(:gb_nir, :informal)[0][:name]
|
||||
|
||||
assert_equal 'Christmas Day', Date.civil(2008,12,25).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Christmas Day', Date.civil(2009,12,25).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Christmas Day', Date.civil(2010,12,27).holidays(:gb_, :observed)[0][:name]
|
||||
|
||||
assert_equal 'Boxing Day', Date.civil(2008,12,26).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Boxing Day', Date.civil(2009,12,28).holidays(:gb_, :observed)[0][:name]
|
||||
assert_equal 'Boxing Day', Date.civil(2010,12,28).holidays(:gb_, :observed)[0][:name]
|
||||
|
||||
[:gb_wls, :gb_eng, :gb_nir, :gb_eaw, :gb_].each do |r|
|
||||
assert_equal 'Easter Monday', Date.civil(2008,3,24).holidays(r)[0][:name]
|
||||
assert_equal 'Bank Holiday', Date.civil(2008,8,25).holidays(r)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_ie
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,3,17) => 'St. Patrick\'s Day',
|
||||
Date.civil(2008,3,24) => 'Easter Monday',
|
||||
Date.civil(2008,5,5) => 'May Day',
|
||||
Date.civil(2008,6,2) => 'Bank Holiday',
|
||||
Date.civil(2008,8,4) => 'Bank Holiday',
|
||||
Date.civil(2008,12,25) => 'Christmas Day',
|
||||
Date.civil(2008,12,26) => 'St. Stephen\'s Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :ie, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_it
|
||||
{Date.civil(2007,1,1) => 'Capodanno',
|
||||
Date.civil(2007,1,6) => 'Epifania',
|
||||
Date.civil(2007,4,8) => 'Pasqua',
|
||||
Date.civil(2007,4,9) => 'Lunedì dell\'Angelo',
|
||||
Date.civil(2007,4,25) => 'Festa della Liberazione',
|
||||
Date.civil(2007,5,1) => 'Festa dei Lavoratori',
|
||||
Date.civil(2007,6,2) => 'Festa della Repubblica',
|
||||
Date.civil(2007,8,15) => 'Assunzione',
|
||||
Date.civil(2007,11,1) => 'Ognissanti',
|
||||
Date.civil(2007,12,8) => 'Immacolata Concezione',
|
||||
Date.civil(2007,12,25) => 'Natale',
|
||||
Date.civil(2007,12,26) => 'Santo Stefano'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :it, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
def test_is
|
||||
{Date.civil(2007,1,1) => 'Nýársdagur',
|
||||
Date.civil(2007,1,6) => 'Þrettándinn',
|
||||
Date.civil(2007,1,19) => 'Bóndadagur',
|
||||
Date.civil(2007,2,18) => 'Konudagur',
|
||||
Date.civil(2007,4,5) => 'Skírdagur',
|
||||
Date.civil(2007,4,6) => 'Föstudaginn langi',
|
||||
Date.civil(2007,4,8) => 'Páskadagur',
|
||||
Date.civil(2007,4,9) => 'Annar í páskum',
|
||||
Date.civil(2007,4,19) => 'Sumardagurinn fyrsti',
|
||||
Date.civil(2007,5,1) => 'Verkalýðsdagurinn',
|
||||
Date.civil(2007,5,17) => 'Uppstigningardagur',
|
||||
Date.civil(2007,5,27) => 'Hvítasunnudagur',
|
||||
Date.civil(2007,5,28) => 'Annar í hvítasunnu',
|
||||
Date.civil(2007,6,3) => 'Sjómannadagurinn',
|
||||
Date.civil(2007,6,17) => 'Lýðveldisdagurinn',
|
||||
Date.civil(2007,8,6) => 'Frídagur verslunarmanna',
|
||||
Date.civil(2007,12,24) => 'Jól',
|
||||
Date.civil(2007,12,25) => 'Jól',
|
||||
Date.civil(2007,12,26) => 'Jól',
|
||||
Date.civil(2007,12,31) => 'Gamlárskvöld'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :is, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
def test_nl
|
||||
{Date.civil(2008,1,1) => 'Nieuwjaar',
|
||||
Date.civil(2008,3,21) => 'Goede Vrijdag',
|
||||
Date.civil(2008,3,23) => 'Pasen',
|
||||
Date.civil(2008,3,24) => 'Pasen',
|
||||
Date.civil(2008,4,30) => 'Koninginnedag',
|
||||
Date.civil(2008,5,1) => 'Hemelvaartsdag', # Ascension, Easter+39
|
||||
Date.civil(2008,5,5) => 'Bevrijdingsdag',
|
||||
Date.civil(2008,5,11) => 'Pinksteren', # Pentecost, Easter+49
|
||||
Date.civil(2008,5,12) => 'Pinksteren', # Pentecost, Easter+50
|
||||
Date.civil(2008,12,25) => 'Kerstmis',
|
||||
Date.civil(2008,12,26) => 'Kerstmis'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :nl, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
def test_pt
|
||||
{Date.civil(2008,1,1) => 'Ano Novo',
|
||||
Date.civil(2005,2,8) => 'Carnaval',
|
||||
Date.civil(2006,2,28) => 'Carnaval',
|
||||
Date.civil(2007,2,20) => 'Carnaval',
|
||||
Date.civil(2008,2,5) => 'Carnaval',
|
||||
Date.civil(2008,3,21) => 'Sexta-feira Santa',
|
||||
Date.civil(2008,3,23) => 'Páscoa',
|
||||
Date.civil(2008,4,25) => 'Dia da Liberdade',
|
||||
Date.civil(2008,5,1) => 'Dia do Trabalhador',
|
||||
Date.civil(2005,5,26) => 'Corpo de Deus',
|
||||
Date.civil(2007,6,7) => 'Corpo de Deus',
|
||||
Date.civil(2008,5,22) => 'Corpo de Deus',
|
||||
Date.civil(2008,6,10) => 'Dia de Portugal',
|
||||
Date.civil(2008,8,15) => 'Assunção de Nossa Senhora',
|
||||
Date.civil(2008,10,5) => 'Implantação da República',
|
||||
Date.civil(2008,11,1) => 'Todos os Santos',
|
||||
Date.civil(2008,12,1) => 'Restauração da Independência',
|
||||
Date.civil(2008,12,8) => 'Imaculada Conceição',
|
||||
Date.civil(2008,12,25) => 'Natal'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :pt, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
def test_se
|
||||
{Date.civil(2008,1,1) => 'Nyårsdagen',
|
||||
Date.civil(2008,1,6) => 'Trettondedag jul',
|
||||
Date.civil(2008,3,21) => 'Långfredagen',
|
||||
Date.civil(2008,3,23) => 'Påskdagen',
|
||||
Date.civil(2008,3,24) => 'Annandag påsk',
|
||||
Date.civil(2008,5,1) => 'Första maj',
|
||||
Date.civil(2008,5,1) => 'Kristi himmelsfärdsdag',
|
||||
Date.civil(2008,5,11) => 'Pingstdagen',
|
||||
Date.civil(2008,6,6) => 'Nationaldagen',
|
||||
Date.civil(2005,6,25) => 'Midsommardagen',
|
||||
Date.civil(2006,6,24) => 'Midsommardagen',
|
||||
Date.civil(2007,6,23) => 'Midsommardagen',
|
||||
Date.civil(2008,6,21) => 'Midsommardagen',
|
||||
Date.civil(2005,11,5) => 'Alla helgons dag',
|
||||
Date.civil(2006,11,4) => 'Alla helgons dag',
|
||||
Date.civil(2007,11,3) => 'Alla helgons dag',
|
||||
Date.civil(2008,11,1) => 'Alla helgons dag',
|
||||
Date.civil(2008,12,25) => 'Juldagen',
|
||||
Date.civil(2008,12,26) => 'Annandag jul'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :se, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
require 'holidays/za'
|
||||
|
||||
class ZATests < Test::Unit::TestCase
|
||||
def test_za
|
||||
{Date.civil(2007,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2007,3,21) => 'Human Rights Day',
|
||||
Date.civil(2007,4,6) => 'Good Friday',
|
||||
Date.civil(2007,4,9) => 'Family Day',
|
||||
Date.civil(2007,4,27) => 'Freedom Day',
|
||||
Date.civil(2007,5,1) => 'Workers Day',
|
||||
Date.civil(2007,6,16) => 'Youth Day',
|
||||
Date.civil(2007,8,9) => 'National Women\'s Day',
|
||||
Date.civil(2007,9,24) => 'Heritage Day',
|
||||
Date.civil(2007,12,16) => 'Day of Reconciliation',
|
||||
Date.civil(2007,12,25) => 'Christmas Day',
|
||||
Date.civil(2007,12,26) => 'Day of Goodwill'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :za, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,60 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/test_helper'
|
||||
|
||||
require 'holidays/north_america'
|
||||
|
||||
class North_AmericaTests < Test::Unit::TestCase
|
||||
|
||||
def test_ca
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,3,21) => 'Good Friday',
|
||||
Date.civil(2008,3,24) => 'Easter Monday',
|
||||
Date.civil(2008,5,19) => 'Victoria Day',
|
||||
Date.civil(2008,7,1) => 'Canada Day',
|
||||
Date.civil(2008,9,1) => 'Labour Day',
|
||||
Date.civil(2008,10,13) => 'Thanksgiving',
|
||||
Date.civil(2008,11,11) => 'Rememberance Day',
|
||||
Date.civil(2008,12,25) => 'Christmas Day',
|
||||
Date.civil(2008,12,26) => 'Boxing Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :ca, :informal)[0][:name]
|
||||
end
|
||||
|
||||
# Victoria Day
|
||||
[Date.civil(2004,5,24), Date.civil(2005,5,23), Date.civil(2006,5,22),
|
||||
Date.civil(2007,5,21), Date.civil(2008,5,19)].each do |date|
|
||||
assert_equal 'Victoria Day', Holidays.on(date, :ca)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
# from
|
||||
# - http://www.britishembassy.gov.uk/servlet/Front?pagename=OpenMarket/Xcelerate/ShowPage&c=Page&cid=1125561634963
|
||||
# - http://www.usembassy-mexico.gov/eng/holidays.html
|
||||
def test_mx
|
||||
{Date.civil(2007,1,1) => 'Año nuevo',
|
||||
Date.civil(2007,2,5) => 'Día de la Constitución',
|
||||
Date.civil(2007,5,1) => 'Día del Trabajo',
|
||||
Date.civil(2007,5,5) => 'Cinco de Mayo',
|
||||
Date.civil(2007,9,16) => 'Día de la Independencia',
|
||||
Date.civil(2007,11,1) => 'Todos los Santos',
|
||||
Date.civil(2007,11,2) => 'Los Fieles Difuntos',
|
||||
Date.civil(2007,11,19) => 'Día de la Revolución',
|
||||
Date.civil(2007,12,25) => 'Navidad'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :mx, :informal)[0][:name]
|
||||
end
|
||||
end
|
||||
|
||||
def test_us
|
||||
{Date.civil(2008,1,1) => 'New Year\'s Day',
|
||||
Date.civil(2008,1,21) => 'Martin Luther King, Jr. Day',
|
||||
Date.civil(2008,2,18) => 'Presidents\' Day',
|
||||
Date.civil(2008,5,26) => 'Memorial Day',
|
||||
Date.civil(2008,7,4) => 'Independence Day',
|
||||
Date.civil(2008,9,1) => 'Labor Day',
|
||||
Date.civil(2008,10,13) => 'Columbus Day',
|
||||
Date.civil(2008,11,11) => 'Veterans Day',
|
||||
Date.civil(2008,11,27) => 'Thanksgiving',
|
||||
Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name|
|
||||
assert_equal name, Holidays.on(date, :us)[0][:name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Reference in a new issue