From 0730f27b2c8eab5e7e1ff9a28be1c2b7f9c1a7db Mon Sep 17 00:00:00 2001 From: Alex Dunae Date: Tue, 30 Dec 2008 11:43:29 -0800 Subject: [PATCH] Fixed definition index -- PT was using SE defs -- thanks Jaoa Miguel Neves --- data/au.yaml | 210 +++---- data/ca.yaml | 280 +++++----- data/index.yaml | 2 +- data/united_nations.yaml | 376 ++++++------- data/ups.yaml | 110 ++-- data/us.yaml | 160 +++--- lib/holidays.rb | 806 +++++++++++++-------------- lib/holidays/MANIFEST | 50 +- lib/holidays/au.rb | 82 +-- lib/holidays/ca.rb | 136 ++--- lib/holidays/de.rb | 104 ++-- lib/holidays/dk.rb | 94 ++-- lib/holidays/es.rb | 104 ++-- lib/holidays/europe.rb | 430 +++++++------- lib/holidays/fr.rb | 72 +-- lib/holidays/gb.rb | 80 +-- lib/holidays/ie.rb | 64 +-- lib/holidays/is.rb | 122 ++-- lib/holidays/it.rb | 70 +-- lib/holidays/mx.rb | 102 ++-- lib/holidays/nl.rb | 72 +-- lib/holidays/north_america.rb | 214 +++---- lib/holidays/nyse.rb | 64 +-- lib/holidays/pt.rb | 89 ++- lib/holidays/scandinavia.rb | 228 ++++---- lib/holidays/se.rb | 104 ++-- lib/holidays/united_nations.rb | 48 +- lib/holidays/ups.rb | 62 +-- lib/holidays/us.rb | 96 ++-- lib/holidays/za.rb | 70 +-- test/defs/test_defs_au.rb | 72 +-- test/defs/test_defs_ca.rb | 58 +- test/defs/test_defs_de.rb | 92 +-- test/defs/test_defs_dk.rb | 60 +- test/defs/test_defs_es.rb | 114 ++-- test/defs/test_defs_europe.rb | 480 ++++++++-------- test/defs/test_defs_fr.rb | 52 +- test/defs/test_defs_gb.rb | 72 +-- test/defs/test_defs_ie.rb | 42 +- test/defs/test_defs_is.rb | 66 +-- test/defs/test_defs_it.rb | 50 +- test/defs/test_defs_mx.rb | 44 +- test/defs/test_defs_nl.rb | 48 +- test/defs/test_defs_north_america.rb | 108 ++-- test/defs/test_defs_nyse.rb | 44 +- test/defs/test_defs_pt.rb | 64 +-- test/defs/test_defs_scandinavia.rb | 150 ++--- test/defs/test_defs_se.rb | 64 +-- test/defs/test_defs_ups.rb | 42 +- test/defs/test_defs_us.rb | 46 +- test/defs/test_defs_za.rb | 50 +- 51 files changed, 3152 insertions(+), 3167 deletions(-) diff --git a/data/au.yaml b/data/au.yaml index 3ae0183..3af3070 100644 --- a/data/au.yaml +++ b/data/au.yaml @@ -1,106 +1,106 @@ -# Australian holiday definitions for the Ruby Holiday gem. -# Updated: 2008-11-29. -# Sources: -# - http://en.wikipedia.org/wiki/Australian_public_holidays -# - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html -# - http://www.wst.tas.gov.au/employment_info/public_holidays -# TODO: missing some regional holidays ---- -months: - 0: - - name: Good Friday - regions: [au] - function: easter(year)-2 - - name: Easter Saturday - regions: [au] - function: easter(year)-1 - - name: Easter Monday - regions: [au] - function: easter(year)+1 - - name: Easter Monday - regions: [au_tas] - function: easter(year)+2 - 1: - - name: New Year's Day - regions: [au] - mday: 1 - - name: Australia Day - regions: [au] - mday: 26 - 3: - - name: Labour Day - regions: [au_wa] - week: 1 - wday: 1 - - name: Eight Hours Day - regions: [au_tas] - week: 2 - wday: 1 - - name: Labour Day - regions: [au_vic] - week: 2 - wday: 1 - 4: - - name: ANZAC Day - regions: [au] - mday: 25 - 5: - - name: Labour Day - regions: [au_qld] - week: 1 - wday: 1 - - name: May Day - regions: [au_nt] - week: 1 - wday: 1 - 6: - - name: Foundation Day - regions: [au_wa] - week: 1 - wday: 1 - - name: Queen's Birthday - regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_qld, au_vic] - week: 2 - wday: 1 - - name: Queensland Day - regions: [au_qld] - mday: 6 - type: informal - 10: - - name: Labour Day - regions: [au_act, au_nsw, au_sa] - week: 1 - wday: 1 - 12: - - name: Christmas Day - regions: [au] - mday: 25 - - name: Boxing Day - regions: [au] - mday: 26 -tests: | - {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] - +# Australian holiday definitions for the Ruby Holiday gem. +# Updated: 2008-11-29. +# Sources: +# - http://en.wikipedia.org/wiki/Australian_public_holidays +# - http://www.docep.wa.gov.au/lr/LabourRelations/Content/Wages%20and%20Conditions/Public%20Holidays/Public_Holidays.html +# - http://www.wst.tas.gov.au/employment_info/public_holidays +# TODO: missing some regional holidays +--- +months: + 0: + - name: Good Friday + regions: [au] + function: easter(year)-2 + - name: Easter Saturday + regions: [au] + function: easter(year)-1 + - name: Easter Monday + regions: [au] + function: easter(year)+1 + - name: Easter Monday + regions: [au_tas] + function: easter(year)+2 + 1: + - name: New Year's Day + regions: [au] + mday: 1 + - name: Australia Day + regions: [au] + mday: 26 + 3: + - name: Labour Day + regions: [au_wa] + week: 1 + wday: 1 + - name: Eight Hours Day + regions: [au_tas] + week: 2 + wday: 1 + - name: Labour Day + regions: [au_vic] + week: 2 + wday: 1 + 4: + - name: ANZAC Day + regions: [au] + mday: 25 + 5: + - name: Labour Day + regions: [au_qld] + week: 1 + wday: 1 + - name: May Day + regions: [au_nt] + week: 1 + wday: 1 + 6: + - name: Foundation Day + regions: [au_wa] + week: 1 + wday: 1 + - name: Queen's Birthday + regions: [au_act, au_nsw, au_sa, au_tas, au_nt, au_qld, au_vic] + week: 2 + wday: 1 + - name: Queensland Day + regions: [au_qld] + mday: 6 + type: informal + 10: + - name: Labour Day + regions: [au_act, au_nsw, au_sa] + week: 1 + wday: 1 + 12: + - name: Christmas Day + regions: [au] + mday: 25 + - name: Boxing Day + regions: [au] + mday: 26 +tests: | + {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] \ No newline at end of file diff --git a/data/ca.yaml b/data/ca.yaml index b18bbe9..2bcd540 100644 --- a/data/ca.yaml +++ b/data/ca.yaml @@ -1,141 +1,141 @@ -# Canadian holiday definitions for the Ruby Holiday gem. -# Updated 2008-11-21. ---- -months: - 0: - - name: Good Friday - regions: [ca] - function: easter(year)-2 - - name: Easter Monday - regions: [ca] - function: easter(year)+1 - type: informal - 1: - - name: New Year's Day - regions: [ca] - mday: 1 - - name: New Year's - regions: [ca_qc] - mday: 2 - 2: - - name: Family Day - regions: [ca_ab, ca_on, ca_sk] - wday: 1 - week: 3 - - name: Louis Riel Day - regions: [ca_mb] - wday: 1 - week: 3 - 3: - - name: St. Patrick's Day - regions: [ca_nf] - mday: 17 - 3: - - name: St. George's Day - regions: [ca_nf] - mday: 23 - 5: - - name: Victoria Day - regions: [ca] - function: ca_victoria_day(year) - - name: National Patriotes Day - regions: [ca_qc] - function: ca_victoria_day(year) - 6: - - name: Discovery Day - regions: [ca_nf] - mday: 24 - - name: Fête Nationale - regions: [ca_qc] - mday: 24 - - name: National Aboriginal Day - regions: [ca_nt] - mday: 21 - 7: - - name: Canada Day - regions: [ca] - mday: 1 - observed: to_monday_if_sunday - - name: Orangemen's Day - regions: [ca_nf] - mday: 12 - - name: Nunavut Day - regions: [ca_nu] - mday: 9 - 8: - - name: BC Day - week: 1 - regions: [ca_bc] - wday: 1 - - name: Saskatchewan Day - week: 1 - regions: [ca_sk] - wday: 1 - - name: Heritage Day - week: 1 - regions: [ca_ab] - wday: 1 - - name: Natal Day - week: 1 - regions: [ca_ns] - wday: 1 - - name: Civic Holiday - week: 1 - regions: [ca_on] - wday: 1 - - name: Discovery Day - week: 3 - regions: [ca_yk] - wday: 1 - 9: - - name: Labour Day - week: 1 - regions: [ca] - wday: 1 - 10: - - name: Thanksgiving - week: 2 - regions: [ca] - wday: 1 - 11: - - name: Rememberance Day - regions: [ca] - mday: 11 - 12: - - name: Christmas Day - regions: [ca] - mday: 25 - - name: Boxing Day - regions: [ca] - mday: 26 -methods: - ca_victoria_day: | - # 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 -tests: | - {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] +# Canadian holiday definitions for the Ruby Holiday gem. +# Updated 2008-11-21. +--- +months: + 0: + - name: Good Friday + regions: [ca] + function: easter(year)-2 + - name: Easter Monday + regions: [ca] + function: easter(year)+1 + type: informal + 1: + - name: New Year's Day + regions: [ca] + mday: 1 + - name: New Year's + regions: [ca_qc] + mday: 2 + 2: + - name: Family Day + regions: [ca_ab, ca_on, ca_sk] + wday: 1 + week: 3 + - name: Louis Riel Day + regions: [ca_mb] + wday: 1 + week: 3 + 3: + - name: St. Patrick's Day + regions: [ca_nf] + mday: 17 + 3: + - name: St. George's Day + regions: [ca_nf] + mday: 23 + 5: + - name: Victoria Day + regions: [ca] + function: ca_victoria_day(year) + - name: National Patriotes Day + regions: [ca_qc] + function: ca_victoria_day(year) + 6: + - name: Discovery Day + regions: [ca_nf] + mday: 24 + - name: Fête Nationale + regions: [ca_qc] + mday: 24 + - name: National Aboriginal Day + regions: [ca_nt] + mday: 21 + 7: + - name: Canada Day + regions: [ca] + mday: 1 + observed: to_monday_if_sunday + - name: Orangemen's Day + regions: [ca_nf] + mday: 12 + - name: Nunavut Day + regions: [ca_nu] + mday: 9 + 8: + - name: BC Day + week: 1 + regions: [ca_bc] + wday: 1 + - name: Saskatchewan Day + week: 1 + regions: [ca_sk] + wday: 1 + - name: Heritage Day + week: 1 + regions: [ca_ab] + wday: 1 + - name: Natal Day + week: 1 + regions: [ca_ns] + wday: 1 + - name: Civic Holiday + week: 1 + regions: [ca_on] + wday: 1 + - name: Discovery Day + week: 3 + regions: [ca_yk] + wday: 1 + 9: + - name: Labour Day + week: 1 + regions: [ca] + wday: 1 + 10: + - name: Thanksgiving + week: 2 + regions: [ca] + wday: 1 + 11: + - name: Rememberance Day + regions: [ca] + mday: 11 + 12: + - name: Christmas Day + regions: [ca] + mday: 25 + - name: Boxing Day + regions: [ca] + mday: 26 +methods: + ca_victoria_day: | + # 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 +tests: | + {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 \ No newline at end of file diff --git a/data/index.yaml b/data/index.yaml index 6ef2e3c..5aa1d2b 100644 --- a/data/index.yaml +++ b/data/index.yaml @@ -14,7 +14,7 @@ defs: MX: ['mx.yaml', 'north_america_informal.yaml'] NL: ['nl.yaml'] NYSE: ['nyse.yaml'] - PT: ['se.yaml'] + PT: ['pt.yaml'] US: ['us.yaml', 'north_america_informal.yaml'] United_Nations: ['united_nations.yaml'] UPS: ['ups.yaml'] diff --git a/data/united_nations.yaml b/data/united_nations.yaml index 13addd1..dee27ab 100644 --- a/data/united_nations.yaml +++ b/data/united_nations.yaml @@ -1,188 +1,188 @@ -# United Nationas holiday definitions for the Ruby Holiday gem. -# Updated 2008-11-21. ---- -2: -- name: International Mother Language Day - regions: [un] - mday: 2 -3: -- name: United Nations Day for Women's Rights and International Peace - regions: [un] - mday: 8 -- name: International Day for the Elimination of Racial Discrimination - regions: [un] - mday: 21 -- name: Beginning of the Week of Solidarity with the Peoples Struggling against Racism and Racial Discrimination - regions: [un] - mday: 21 -- name: World Day for Water - regions: [un] - mday: 22 -- name: World Meteorological Day - regions: [un] - mday: 23 -4: -- name: World Health Day - regions: [un] - mday: 7 -- name: World Book and Copyright Day - regions: [un] - mday: 23 -5: -- name: World Press Freedom Day - regions: [un] - mday: 3 -- name: International Day of Families - regions: [un] - mday: 15 -- name: World Telecommunication Day - regions: [un] - mday: 17 -- name: World Day for Cultural Diversity for Dialogue and Development - regions: [un] - mday: 21 -- name: International Day for Biological Diversity - regions: [un] - mday: 22 -- name: Beginning of the Week of Solidarity with the Peoples of Non-Self-Governing Territories - regions: [un] - mday: 25 -- name: International Day of United Nations Peacekeepers - regions: [un] - mday: 29 -- name: World No-Tobacco Day - regions: [un] - mday: 31 -6: -- name: International Day of Innocent Children Victims of Aggression - regions: [un] - mday: 4 -- name: World Environment Day - regions: [un] - mday: 5 -- name: World Day to Combat Desertification and Drought - regions: [un] - mday: 17 -- name: World Refugee Day - regions: [un] - mday: 20 -- name: United Nations Public Service Day - regions: [un] - mday: 23 -- name: International Day against Drug Abuse and Illicit Trafficking - regions: [un] - mday: 26 -- name: International Day in Support of Victims of Torture - regions: [un] - mday: 26 -7: -- name: International Day of Cooperatives - week: 1 - regions: [un] - wday: 6 -- name: World Population Day - regions: [un] - mday: 11 -8: -- name: International Day of the World's Indigenous People - regions: [un] - mday: 9 -- name: International Youth Day - regions: [un] - mday: 12 -- name: International Day for the Remembrance of the Slave Trade and Its Abolition - regions: [un] - mday: 23 -9: -- name: International Literacy Day - regions: [un] - mday: 8 -- name: International Day for the Preservation of the Ozone Layer - regions: [un] - mday: 16 -- name: International Day of Peace - regions: [un] - mday: 21 -- name: International Day of Older Persons - regions: [un] - mday: 1 -10: -- name: World Space Week - regions: [un] - mday: 4 -- name: World Teachers' Day - regions: [un] - mday: 5 -- name: World Habitat Day - week: 1 - regions: [un] - wday: 1 -- name: International Day for Natural Disaster Reduction - week: 2 - regions: [un] - wday: 3 -- name: World Post Day - regions: [un] - mday: 9 -- name: World Mental Health Day - regions: [un] - mday: 10 -- name: World Food Day - regions: [un] - mday: 16 -- name: International Day for the Eradication of Poverty - regions: [un] - mday: 17 -- name: United Nations Day - regions: [un] - mday: 24 -- name: World Development Information Day - regions: [un] - mday: 24 -- name: Disarmament Week - regions: [un] - mday: 24 -11: -- name: International Day for Preventing the Exploitation of the Environment in War and Armed Conflict - regions: [un] - mday: 6 -- name: International Day for Tolerance - regions: [un] - mday: 16 -- name: Africa Industrialization Day - regions: [un] - mday: 20 -- name: Universal Children's Day - regions: [un] - mday: 20 -- name: World Television Day - regions: [un] - mday: 21 -- name: International Day for the Elimination of Violence against Women - regions: [un] - mday: 25 -- name: International Day of Solidarity with the Palestinian People - regions: [un] - mday: 29 -12: -- name: World AIDS Day - regions: [un] - mday: 1 -- name: International Day for the Abolition of Slavery - regions: [un] - mday: 2 -- name: International Day of Disabled Persons - regions: [un] - mday: 3 -- name: International Volunteer Day for Economic and Social Development - regions: [un] - mday: 5 -- name: International Civil Aviation Day - regions: [un] - mday: 7 -- name: Human Rights Day - regions: [un] - mday: 10 -- name: International Migrants Day - regions: [un] - mday: 18 +# United Nationas holiday definitions for the Ruby Holiday gem. +# Updated 2008-11-21. +--- +2: +- name: International Mother Language Day + regions: [un] + mday: 2 +3: +- name: United Nations Day for Women's Rights and International Peace + regions: [un] + mday: 8 +- name: International Day for the Elimination of Racial Discrimination + regions: [un] + mday: 21 +- name: Beginning of the Week of Solidarity with the Peoples Struggling against Racism and Racial Discrimination + regions: [un] + mday: 21 +- name: World Day for Water + regions: [un] + mday: 22 +- name: World Meteorological Day + regions: [un] + mday: 23 +4: +- name: World Health Day + regions: [un] + mday: 7 +- name: World Book and Copyright Day + regions: [un] + mday: 23 +5: +- name: World Press Freedom Day + regions: [un] + mday: 3 +- name: International Day of Families + regions: [un] + mday: 15 +- name: World Telecommunication Day + regions: [un] + mday: 17 +- name: World Day for Cultural Diversity for Dialogue and Development + regions: [un] + mday: 21 +- name: International Day for Biological Diversity + regions: [un] + mday: 22 +- name: Beginning of the Week of Solidarity with the Peoples of Non-Self-Governing Territories + regions: [un] + mday: 25 +- name: International Day of United Nations Peacekeepers + regions: [un] + mday: 29 +- name: World No-Tobacco Day + regions: [un] + mday: 31 +6: +- name: International Day of Innocent Children Victims of Aggression + regions: [un] + mday: 4 +- name: World Environment Day + regions: [un] + mday: 5 +- name: World Day to Combat Desertification and Drought + regions: [un] + mday: 17 +- name: World Refugee Day + regions: [un] + mday: 20 +- name: United Nations Public Service Day + regions: [un] + mday: 23 +- name: International Day against Drug Abuse and Illicit Trafficking + regions: [un] + mday: 26 +- name: International Day in Support of Victims of Torture + regions: [un] + mday: 26 +7: +- name: International Day of Cooperatives + week: 1 + regions: [un] + wday: 6 +- name: World Population Day + regions: [un] + mday: 11 +8: +- name: International Day of the World's Indigenous People + regions: [un] + mday: 9 +- name: International Youth Day + regions: [un] + mday: 12 +- name: International Day for the Remembrance of the Slave Trade and Its Abolition + regions: [un] + mday: 23 +9: +- name: International Literacy Day + regions: [un] + mday: 8 +- name: International Day for the Preservation of the Ozone Layer + regions: [un] + mday: 16 +- name: International Day of Peace + regions: [un] + mday: 21 +- name: International Day of Older Persons + regions: [un] + mday: 1 +10: +- name: World Space Week + regions: [un] + mday: 4 +- name: World Teachers' Day + regions: [un] + mday: 5 +- name: World Habitat Day + week: 1 + regions: [un] + wday: 1 +- name: International Day for Natural Disaster Reduction + week: 2 + regions: [un] + wday: 3 +- name: World Post Day + regions: [un] + mday: 9 +- name: World Mental Health Day + regions: [un] + mday: 10 +- name: World Food Day + regions: [un] + mday: 16 +- name: International Day for the Eradication of Poverty + regions: [un] + mday: 17 +- name: United Nations Day + regions: [un] + mday: 24 +- name: World Development Information Day + regions: [un] + mday: 24 +- name: Disarmament Week + regions: [un] + mday: 24 +11: +- name: International Day for Preventing the Exploitation of the Environment in War and Armed Conflict + regions: [un] + mday: 6 +- name: International Day for Tolerance + regions: [un] + mday: 16 +- name: Africa Industrialization Day + regions: [un] + mday: 20 +- name: Universal Children's Day + regions: [un] + mday: 20 +- name: World Television Day + regions: [un] + mday: 21 +- name: International Day for the Elimination of Violence against Women + regions: [un] + mday: 25 +- name: International Day of Solidarity with the Palestinian People + regions: [un] + mday: 29 +12: +- name: World AIDS Day + regions: [un] + mday: 1 +- name: International Day for the Abolition of Slavery + regions: [un] + mday: 2 +- name: International Day of Disabled Persons + regions: [un] + mday: 3 +- name: International Volunteer Day for Economic and Social Development + regions: [un] + mday: 5 +- name: International Civil Aviation Day + regions: [un] + mday: 7 +- name: Human Rights Day + regions: [un] + mday: 10 +- name: International Migrants Day + regions: [un] + mday: 18 diff --git a/data/ups.yaml b/data/ups.yaml index 8db4402..4ffcf17 100644 --- a/data/ups.yaml +++ b/data/ups.yaml @@ -1,56 +1,56 @@ -# UPS holiday definitions for the Ruby Holiday gem. -# -# By Tim Anglade -# -# Updated: 2008-09-23. -# Source: http://www.ups.com/content/us/en/resources/ship/imp_exp/operation.html ---- -months: - 1: - - name: New Year's Day - regions: [ups] - mday: 1 - observed: to_weekday_if_weekend - 5: - - name: Memorial Day - week: -1 - regions: [ups] - wday: 1 - 7: - - name: Independence Day - regions: [ups] - mday: 4 - observed: to_weekday_if_weekend - 9: - - name: Labor Day - week: 1 - regions: [ups] - wday: 1 - 11: - - name: Thanksgiving - week: 4 - regions: [ups] - wday: 4 - - name: Day After Thanksgiving - week: 4 - regions: [ups] - wday: 5 - 12: - - name: Christmas Day - regions: [ups] - mday: 25 - observed: to_weekday_if_weekend - - name: New Year's Eve - regions: [ups] - mday: 31 -tests: | - {Date.civil(2008,1,1) => 'New Year\'s 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,11,27) => 'Thanksgiving', - Date.civil(2008,11,28) => 'Day After Thanksgiving', - Date.civil(2008,12,25) => 'Christmas Day', - Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name| - assert_equal name, Holidays.on(date, :ups)[0][:name] +# UPS holiday definitions for the Ruby Holiday gem. +# +# By Tim Anglade +# +# Updated: 2008-09-23. +# Source: http://www.ups.com/content/us/en/resources/ship/imp_exp/operation.html +--- +months: + 1: + - name: New Year's Day + regions: [ups] + mday: 1 + observed: to_weekday_if_weekend + 5: + - name: Memorial Day + week: -1 + regions: [ups] + wday: 1 + 7: + - name: Independence Day + regions: [ups] + mday: 4 + observed: to_weekday_if_weekend + 9: + - name: Labor Day + week: 1 + regions: [ups] + wday: 1 + 11: + - name: Thanksgiving + week: 4 + regions: [ups] + wday: 4 + - name: Day After Thanksgiving + week: 4 + regions: [ups] + wday: 5 + 12: + - name: Christmas Day + regions: [ups] + mday: 25 + observed: to_weekday_if_weekend + - name: New Year's Eve + regions: [ups] + mday: 31 +tests: | + {Date.civil(2008,1,1) => 'New Year\'s 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,11,27) => 'Thanksgiving', + Date.civil(2008,11,28) => 'Day After Thanksgiving', + Date.civil(2008,12,25) => 'Christmas Day', + Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name| + assert_equal name, Holidays.on(date, :ups)[0][:name] end \ No newline at end of file diff --git a/data/us.yaml b/data/us.yaml index 3bf7307..0137baa 100644 --- a/data/us.yaml +++ b/data/us.yaml @@ -1,81 +1,81 @@ -# United States holiday definitions for the Ruby Holiday gem. -# -# Updated: 2008-11-24. -# Source: http://en.wikipedia.org/wiki/Public_holidays_of_the_United_States ---- -months: - 0: - - name: Good Friday - regions: [us] - function: easter(year)-2 - type: informal - 1: - - name: New Year's Day - regions: [us] - mday: 1 - observed: to_weekday_if_weekend - - name: Martin Luther King, Jr. Day - week: 3 - regions: [us] - wday: 1 - - name: Inauguration Day - function: us_inauguration_day(year) - regions: [us_dc] - 2: - - name: Presidents' Day - week: 3 - regions: [us] - wday: 1 - 5: - - name: Memorial Day - week: -1 - regions: [us] - wday: 1 - 7: - - name: Independence Day - regions: [us] - mday: 4 - observed: to_weekday_if_weekend - 9: - - name: Labor Day - week: 1 - regions: [us] - wday: 1 - 10: - - name: Columbus Day - week: 2 - regions: [us] - wday: 1 - 11: - - name: Veterans Day - regions: [us] - mday: 11 - observed: to_weekday_if_weekend - - name: Thanksgiving - week: 4 - regions: [us] - wday: 4 - 12: - - name: Christmas Day - regions: [us] - mday: 25 - observed: to_weekday_if_weekend -methods: - us_inauguration_day: | - # January 20, every fourth year, following Presidential election - def self.us_inauguration_day(year) - year % 4 == 1 ? 20 : nil - end -tests: | - {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] +# United States holiday definitions for the Ruby Holiday gem. +# +# Updated: 2008-11-24. +# Source: http://en.wikipedia.org/wiki/Public_holidays_of_the_United_States +--- +months: + 0: + - name: Good Friday + regions: [us] + function: easter(year)-2 + type: informal + 1: + - name: New Year's Day + regions: [us] + mday: 1 + observed: to_weekday_if_weekend + - name: Martin Luther King, Jr. Day + week: 3 + regions: [us] + wday: 1 + - name: Inauguration Day + function: us_inauguration_day(year) + regions: [us_dc] + 2: + - name: Presidents' Day + week: 3 + regions: [us] + wday: 1 + 5: + - name: Memorial Day + week: -1 + regions: [us] + wday: 1 + 7: + - name: Independence Day + regions: [us] + mday: 4 + observed: to_weekday_if_weekend + 9: + - name: Labor Day + week: 1 + regions: [us] + wday: 1 + 10: + - name: Columbus Day + week: 2 + regions: [us] + wday: 1 + 11: + - name: Veterans Day + regions: [us] + mday: 11 + observed: to_weekday_if_weekend + - name: Thanksgiving + week: 4 + regions: [us] + wday: 4 + 12: + - name: Christmas Day + regions: [us] + mday: 25 + observed: to_weekday_if_weekend +methods: + us_inauguration_day: | + # January 20, every fourth year, following Presidential election + def self.us_inauguration_day(year) + year % 4 == 1 ? 20 : nil + end +tests: | + {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 \ No newline at end of file diff --git a/lib/holidays.rb b/lib/holidays.rb index 5fcec70..7d41b69 100644 --- a/lib/holidays.rb +++ b/lib/holidays.rb @@ -1,404 +1,404 @@ -$:.unshift File.dirname(__FILE__) - -require 'digest/md5' -require 'date' - -# == Region options -# Holidays can be defined as belonging to one or more regions and sub regions. -# The Holidays#on, Holidays#between, Date#holidays and Date#holiday? methods -# each allow you to specify a specific region. -# -# There are several different ways that you can specify a region: -# -# [:region] -# By region. For example, return holidays in the Canada with :ca. -# [:region_] -# By region and sub regions. For example, return holidays in Germany -# and all its sub regions with :de_. -# [:region_sub] -# By sub region. Return national holidays in Spain plus holidays in Spain's -# Valencia region with :es_v. -# [:any] -# Any region. Return holidays from any loaded region. -# -# == Other options -# [:observed] Return holidays on the day they are observed (e.g. on a Monday if they fall on a Sunday). -# [:informal] Include informal holidays (e.g. Valentine's Day) -# -# == Examples -# Return all holidays in the :ca and :us regions on the day that they are -# observed. -# -# Holidays.between(from, to, :ca, :us, :observed) -# -# Return all holidays in :ca and any :ca sub-region. -# -# Holidays.between(from, to, :ca_) -# -# Return all holidays in :ca_bc sub-region (which includes the :ca), including informal holidays. -# -# Holidays.between(from, to, :ca_bc, :informal) -module Holidays - # Exception thrown when an unknown region is requested. - class UnkownRegionError < ArgumentError; end - - VERSION = '0.9.2' - - @@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] - DAY_SYMBOLS = Date::DAYNAMES.collect { |n| n.downcase.intern } - - # Get all holidays on a given date. - # - # [date] A Date object. - # [:options] One or more region symbols, :informal and/or :observed. - # - # Returns an array of hashes or nil. See Holidays#between for the output - # format. - # - # Also available via Date#holidays. - def self.on(date, *options) - self.between(date, date, options) - end - - # Get all holidays occuring between two dates, inclusively. - # - # Returns an array of hashes or nil. - # - # Each holiday is returned as a hash with the following fields: - # [start_date] Ruby Date object. - # [end_date] Ruby Date object. - # [options] One or more region symbols, :informal and/or :observed. - # - # ==== Example - # from = Date.civil(2008,7,1) - # to = Date.civil(2008,7,31) - # - # Holidays.between(from, to, :ca, :us) - # => [{:name => 'Canada Day', :regions => [:ca]...} - # {:name => 'Independence Day'', :regions => [:us], ...}] - def self.between(start_date, end_date, *options) - regions, observed, informal = parse_options(options) - holidays = [] - - dates = {} - (start_date..end_date).each do |date| - # Always include month '0' for variable-month holidays - dates[date.year] = [0] unless dates[date.year] - # TODO: test this, maybe should push then flatten - dates[date.year] << date.month unless dates[date.year].include?(date.month) - end - - dates.each do |year, months| - months.each do |month| - next unless hbm = @@holidays_by_month[month] - - hbm.each do |h| - next unless in_region?(regions, h[:regions]) - - # Skip informal holidays unless they have been requested - next if h[:type] == :informal and not informal - - if h[:function] - # Holiday definition requires a calculation - result = call_proc(h[:function], year) - - # Procs may return either Date or an integer representing mday - if result.kind_of?(Date) - month = result.month - mday = result.mday - else - mday = result - end - else - # Calculate the mday - mday = h[:mday] || Date.calculate_mday(year, month, h[:week], h[:wday]) - end - - # Silently skip bad mdays - begin - date = Date.civil(year, month, mday) - rescue; next; end - - # If the :observed option is set, calculate the date when the holiday - # is observed. - if observed and h[:observed] - date = call_proc(h[:observed], date) - end - - if date.between?(start_date, end_date) - holidays << {:date => date, :name => h[:name], :regions => h[:regions]} - end - - end - end - end - - holidays - end - - # Merge a new set of definitions into the Holidays module. - # - # This method is automatically called when including holiday definition - # files. - def self.merge_defs(regions, holidays) # :nodoc: - @@regions = @@regions | regions - @@regions.uniq! - - holidays.each do |month, holiday_defs| - @@holidays_by_month[month] = [] unless @@holidays_by_month[month] - holiday_defs.each do |holiday_def| - - exists = false - @@holidays_by_month[month].each do |ex| - # TODO: gross. - if ex[:name] == holiday_def[:name] and ex[:wday] == holiday_def[:wday] and ex[:mday] == holiday_def[:mday] and ex[:week] == holiday_def[:week] and ex[:function_id] == holiday_def[:function_id] and ex[:type] == holiday_def[:type] and ex[:observed_id] == holiday_def[:observed_id] - # append regions - ex[:regions] << holiday_def[:regions] - - # Should do this once we're done - ex[:regions].flatten! - ex[:regions].uniq! - exists = true - end - end - - @@holidays_by_month[month] << holiday_def unless exists - end - end - end - - # Get the date of Easter Sunday in a given year. From Easter Sunday, it is - # possible to calculate many traditional holidays in Western countries. - # Returns a Date object. - 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 - - # Move date to Monday if it occurs on a Sunday. - # Used as a callback function. - def self.to_monday_if_sunday(date) - date += 1 if date.wday == 0 - date - end - - # Move date to Monday if it occurs on a Saturday on Sunday. - # Used as a callback function. - def self.to_monday_if_weekend(date) - date += 1 if date.wday == 0 - date += 2 if date.wday == 6 - date - end - - # Move Boxing Day if it falls on a weekend, leaving room for Christmas. - # Used as a callback function. - def self.to_weekday_if_boxing_weekend(date) - date += 2 if date.wday == 6 or date.wday == 0 - date - end - - # Move date to Monday if it occurs on a Sunday or to Friday if it occurs on a - # Saturday. - # Used as a callback function. - def self.to_weekday_if_weekend(date) - date += 1 if date.wday == 0 - date -= 1 if date.wday == 6 - date - end - -private - # Returns [(arr)regions, (bool)observed, (bool)informal] - def self.parse_options(*options) # :nodoc: - options.flatten! - observed = options.delete(:observed) ? true : false - informal = options.delete(:informal) ? true : false - regions = parse_regions(options) - return regions, observed, informal - end - - # Check regions against list of supported regions and return an array of - # symbols. - # - # If a wildcard region is found (e.g. :ca_) it is expanded into all - # of its available sub regions. - def self.parse_regions(regions) # :nodoc: - regions = [regions] unless regions.kind_of?(Array) - return [:any] if regions.empty? - - regions = regions.collect { |r| r.to_sym } - - # Found sub region wild-card - regions.delete_if do |reg| - if reg.to_s =~ /_$/ - regions << @@regions.select { |dr| dr.to_s =~ Regexp.new("^#{reg}") } - true - end - end - - regions.flatten! - - raise UnkownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) } - - regions - end - - # Check sub regions. - # - # When request :any, all holidays should be returned. - # When requesting :ca_bc, holidays in :ca or :ca_bc should be returned. - # When requesting :ca, holidays in :ca but not its subregions should be returned. - def self.in_region?(requested, available) # :nodoc: - return true if requested.include?(:any) - - # When an underscore is encountered, derive the parent regions - # symbol and include both in the requested array. - requested = requested.collect do |r| - r.to_s =~ /_/ ? [r, r.to_s.gsub(/_[\w]*$/, '').to_sym] : r - end - - requested = requested.flatten.uniq - - available.any? { |avail| requested.include?(avail) } - 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 - -# === Extending Ruby's Date class with the Holidays gem -# The Holidays gem automatically extends Ruby's Date class and gives you access -# to three new methods: holiday?, #holidays and #calculate_mday. -# -# ==== Examples -# Lookup Canada Day in the :ca region -# Date.civil(2008,7,1).holiday?(:ca) -# => true -# -# Lookup Canada Day in the :fr region -# Date.civil(2008,7,1).holiday?(:fr) -# => false -# -# Lookup holidays on North America in January 1. -# Date.civil(2008,1,1).holidays(:ca, :mx, :us, :informal, :observed) -# => [{:name => 'New Year\'s Day'...}] -class Date - include Holidays - - # Get holidays on the current date. - # - # Returns an array of hashes or nil. See Holidays#between for options - # and the output format. - # - # Date.civil('2008-01-01').holidays(:ca_) - # => [{:name => 'New Year\'s Day',...}] - # - # Also available via Holidays#on. - def holidays(*options) - Holidays.on(self, options) - end - - # Check if the current date is a holiday. - # - # Returns true or false. - # - # Date.civil('2008-01-01').holiday?(:ca) - # => true - def holiday?(*options) - holidays = self.holidays(options) - holidays && !holidays.empty? - end - - # Calculate day of the month based on the week number and the day of the - # week. - # - # ==== Parameters - # [year] Integer. - # [month] Integer from 1-12. - # [week] One of :first, :second, :third, - # :fourth, :fifth or :last. - # [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: - # Date.calculate_mday(2008, 1, :first, :monday) - # => 7 - # - # Third Thursday of December, 2008: - # Date.calculate_mday(2008, 12, :third, :thursday) - # => 18 - # - # Last Monday of January, 2008: - # Date.calculate_mday(2008, 1, :last, 1) - # => 28 - #-- - # see http://www.irt.org/articles/js050/index.htm - def self.calculate_mday(year, month, week, wday) - raise ArgumentError, "Week parameter must be one of Holidays::WEEKS (provided #{week})." unless WEEKS.include?(week) or WEEKS.has_value?(week) - - unless wday.kind_of?(Numeric) and wday.between?(0,6) or DAY_SYMBOLS.index(wday) - raise ArgumentError, "Wday parameter must be an integer between 0 and 6 or one of Date::DAY_SYMBOLS." - end - - week = WEEKS[week] if week.kind_of?(Symbol) - wday = DAY_SYMBOLS.index(wday) if wday.kind_of?(Symbol) - - # :first, :second, :third, :fourth or :fifth - if week > 0 - return ((week - 1) * 7) + 1 + ((7 + wday - Date.civil(year, month,(week-1)*7 + 1).wday) % 7) - end - - days = MONTH_LENGTHS[month-1] - - days = 29 if month == 1 and Date.civil(year,1,1).leap? - - return days - ((Date.civil(year, month, days).wday - wday + 7) % 7) - end +$:.unshift File.dirname(__FILE__) + +require 'digest/md5' +require 'date' + +# == Region options +# Holidays can be defined as belonging to one or more regions and sub regions. +# The Holidays#on, Holidays#between, Date#holidays and Date#holiday? methods +# each allow you to specify a specific region. +# +# There are several different ways that you can specify a region: +# +# [:region] +# By region. For example, return holidays in the Canada with :ca. +# [:region_] +# By region and sub regions. For example, return holidays in Germany +# and all its sub regions with :de_. +# [:region_sub] +# By sub region. Return national holidays in Spain plus holidays in Spain's +# Valencia region with :es_v. +# [:any] +# Any region. Return holidays from any loaded region. +# +# == Other options +# [:observed] Return holidays on the day they are observed (e.g. on a Monday if they fall on a Sunday). +# [:informal] Include informal holidays (e.g. Valentine's Day) +# +# == Examples +# Return all holidays in the :ca and :us regions on the day that they are +# observed. +# +# Holidays.between(from, to, :ca, :us, :observed) +# +# Return all holidays in :ca and any :ca sub-region. +# +# Holidays.between(from, to, :ca_) +# +# Return all holidays in :ca_bc sub-region (which includes the :ca), including informal holidays. +# +# Holidays.between(from, to, :ca_bc, :informal) +module Holidays + # Exception thrown when an unknown region is requested. + class UnkownRegionError < ArgumentError; end + + VERSION = '0.9.2' + + @@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] + DAY_SYMBOLS = Date::DAYNAMES.collect { |n| n.downcase.intern } + + # Get all holidays on a given date. + # + # [date] A Date object. + # [:options] One or more region symbols, :informal and/or :observed. + # + # Returns an array of hashes or nil. See Holidays#between for the output + # format. + # + # Also available via Date#holidays. + def self.on(date, *options) + self.between(date, date, options) + end + + # Get all holidays occuring between two dates, inclusively. + # + # Returns an array of hashes or nil. + # + # Each holiday is returned as a hash with the following fields: + # [start_date] Ruby Date object. + # [end_date] Ruby Date object. + # [options] One or more region symbols, :informal and/or :observed. + # + # ==== Example + # from = Date.civil(2008,7,1) + # to = Date.civil(2008,7,31) + # + # Holidays.between(from, to, :ca, :us) + # => [{:name => 'Canada Day', :regions => [:ca]...} + # {:name => 'Independence Day'', :regions => [:us], ...}] + def self.between(start_date, end_date, *options) + regions, observed, informal = parse_options(options) + holidays = [] + + dates = {} + (start_date..end_date).each do |date| + # Always include month '0' for variable-month holidays + dates[date.year] = [0] unless dates[date.year] + # TODO: test this, maybe should push then flatten + dates[date.year] << date.month unless dates[date.year].include?(date.month) + end + + dates.each do |year, months| + months.each do |month| + next unless hbm = @@holidays_by_month[month] + + hbm.each do |h| + next unless in_region?(regions, h[:regions]) + + # Skip informal holidays unless they have been requested + next if h[:type] == :informal and not informal + + if h[:function] + # Holiday definition requires a calculation + result = call_proc(h[:function], year) + + # Procs may return either Date or an integer representing mday + if result.kind_of?(Date) + month = result.month + mday = result.mday + else + mday = result + end + else + # Calculate the mday + mday = h[:mday] || Date.calculate_mday(year, month, h[:week], h[:wday]) + end + + # Silently skip bad mdays + begin + date = Date.civil(year, month, mday) + rescue; next; end + + # If the :observed option is set, calculate the date when the holiday + # is observed. + if observed and h[:observed] + date = call_proc(h[:observed], date) + end + + if date.between?(start_date, end_date) + holidays << {:date => date, :name => h[:name], :regions => h[:regions]} + end + + end + end + end + + holidays + end + + # Merge a new set of definitions into the Holidays module. + # + # This method is automatically called when including holiday definition + # files. + def self.merge_defs(regions, holidays) # :nodoc: + @@regions = @@regions | regions + @@regions.uniq! + + holidays.each do |month, holiday_defs| + @@holidays_by_month[month] = [] unless @@holidays_by_month[month] + holiday_defs.each do |holiday_def| + + exists = false + @@holidays_by_month[month].each do |ex| + # TODO: gross. + if ex[:name] == holiday_def[:name] and ex[:wday] == holiday_def[:wday] and ex[:mday] == holiday_def[:mday] and ex[:week] == holiday_def[:week] and ex[:function_id] == holiday_def[:function_id] and ex[:type] == holiday_def[:type] and ex[:observed_id] == holiday_def[:observed_id] + # append regions + ex[:regions] << holiday_def[:regions] + + # Should do this once we're done + ex[:regions].flatten! + ex[:regions].uniq! + exists = true + end + end + + @@holidays_by_month[month] << holiday_def unless exists + end + end + end + + # Get the date of Easter Sunday in a given year. From Easter Sunday, it is + # possible to calculate many traditional holidays in Western countries. + # Returns a Date object. + 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 + + # Move date to Monday if it occurs on a Sunday. + # Used as a callback function. + def self.to_monday_if_sunday(date) + date += 1 if date.wday == 0 + date + end + + # Move date to Monday if it occurs on a Saturday on Sunday. + # Used as a callback function. + def self.to_monday_if_weekend(date) + date += 1 if date.wday == 0 + date += 2 if date.wday == 6 + date + end + + # Move Boxing Day if it falls on a weekend, leaving room for Christmas. + # Used as a callback function. + def self.to_weekday_if_boxing_weekend(date) + date += 2 if date.wday == 6 or date.wday == 0 + date + end + + # Move date to Monday if it occurs on a Sunday or to Friday if it occurs on a + # Saturday. + # Used as a callback function. + def self.to_weekday_if_weekend(date) + date += 1 if date.wday == 0 + date -= 1 if date.wday == 6 + date + end + +private + # Returns [(arr)regions, (bool)observed, (bool)informal] + def self.parse_options(*options) # :nodoc: + options.flatten! + observed = options.delete(:observed) ? true : false + informal = options.delete(:informal) ? true : false + regions = parse_regions(options) + return regions, observed, informal + end + + # Check regions against list of supported regions and return an array of + # symbols. + # + # If a wildcard region is found (e.g. :ca_) it is expanded into all + # of its available sub regions. + def self.parse_regions(regions) # :nodoc: + regions = [regions] unless regions.kind_of?(Array) + return [:any] if regions.empty? + + regions = regions.collect { |r| r.to_sym } + + # Found sub region wild-card + regions.delete_if do |reg| + if reg.to_s =~ /_$/ + regions << @@regions.select { |dr| dr.to_s =~ Regexp.new("^#{reg}") } + true + end + end + + regions.flatten! + + raise UnkownRegionError unless regions.all? { |r| r == :any or @@regions.include?(r) } + + regions + end + + # Check sub regions. + # + # When request :any, all holidays should be returned. + # When requesting :ca_bc, holidays in :ca or :ca_bc should be returned. + # When requesting :ca, holidays in :ca but not its subregions should be returned. + def self.in_region?(requested, available) # :nodoc: + return true if requested.include?(:any) + + # When an underscore is encountered, derive the parent regions + # symbol and include both in the requested array. + requested = requested.collect do |r| + r.to_s =~ /_/ ? [r, r.to_s.gsub(/_[\w]*$/, '').to_sym] : r + end + + requested = requested.flatten.uniq + + available.any? { |avail| requested.include?(avail) } + 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 + +# === Extending Ruby's Date class with the Holidays gem +# The Holidays gem automatically extends Ruby's Date class and gives you access +# to three new methods: holiday?, #holidays and #calculate_mday. +# +# ==== Examples +# Lookup Canada Day in the :ca region +# Date.civil(2008,7,1).holiday?(:ca) +# => true +# +# Lookup Canada Day in the :fr region +# Date.civil(2008,7,1).holiday?(:fr) +# => false +# +# Lookup holidays on North America in January 1. +# Date.civil(2008,1,1).holidays(:ca, :mx, :us, :informal, :observed) +# => [{:name => 'New Year\'s Day'...}] +class Date + include Holidays + + # Get holidays on the current date. + # + # Returns an array of hashes or nil. See Holidays#between for options + # and the output format. + # + # Date.civil('2008-01-01').holidays(:ca_) + # => [{:name => 'New Year\'s Day',...}] + # + # Also available via Holidays#on. + def holidays(*options) + Holidays.on(self, options) + end + + # Check if the current date is a holiday. + # + # Returns true or false. + # + # Date.civil('2008-01-01').holiday?(:ca) + # => true + def holiday?(*options) + holidays = self.holidays(options) + holidays && !holidays.empty? + end + + # Calculate day of the month based on the week number and the day of the + # week. + # + # ==== Parameters + # [year] Integer. + # [month] Integer from 1-12. + # [week] One of :first, :second, :third, + # :fourth, :fifth or :last. + # [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: + # Date.calculate_mday(2008, 1, :first, :monday) + # => 7 + # + # Third Thursday of December, 2008: + # Date.calculate_mday(2008, 12, :third, :thursday) + # => 18 + # + # Last Monday of January, 2008: + # Date.calculate_mday(2008, 1, :last, 1) + # => 28 + #-- + # see http://www.irt.org/articles/js050/index.htm + def self.calculate_mday(year, month, week, wday) + raise ArgumentError, "Week parameter must be one of Holidays::WEEKS (provided #{week})." unless WEEKS.include?(week) or WEEKS.has_value?(week) + + unless wday.kind_of?(Numeric) and wday.between?(0,6) or DAY_SYMBOLS.index(wday) + raise ArgumentError, "Wday parameter must be an integer between 0 and 6 or one of Date::DAY_SYMBOLS." + end + + week = WEEKS[week] if week.kind_of?(Symbol) + wday = DAY_SYMBOLS.index(wday) if wday.kind_of?(Symbol) + + # :first, :second, :third, :fourth or :fifth + if week > 0 + return ((week - 1) * 7) + 1 + ((7 + wday - Date.civil(year, month,(week-1)*7 + 1).wday) % 7) + end + + days = MONTH_LENGTHS[month-1] + + days = 29 if month == 1 and Date.civil(year,1,1).leap? + + return days - ((Date.civil(year, month, days).wday - wday + 7) % 7) + end end \ No newline at end of file diff --git a/lib/holidays/MANIFEST b/lib/holidays/MANIFEST index e4556bc..16abb8b 100644 --- a/lib/holidays/MANIFEST +++ b/lib/holidays/MANIFEST @@ -1,25 +1,25 @@ -==== Regional definitions -The following definition files are included in this installation: - -* holidays/au -* holidays/ca -* holidays/de -* holidays/dk -* holidays/es -* holidays/europe -* holidays/fr -* holidays/gb -* holidays/ie -* holidays/is -* holidays/it -* holidays/mx -* holidays/nl -* holidays/north_america -* holidays/nyse -* holidays/pt -* holidays/scandinavia -* holidays/se -* holidays/united_nations -* holidays/ups -* holidays/us -* holidays/za +==== Regional definitions +The following definition files are included in this installation: + +* holidays/au +* holidays/ca +* holidays/de +* holidays/dk +* holidays/es +* holidays/europe +* holidays/fr +* holidays/gb +* holidays/ie +* holidays/is +* holidays/it +* holidays/mx +* holidays/nl +* holidays/north_america +* holidays/nyse +* holidays/pt +* holidays/scandinavia +* holidays/se +* holidays/united_nations +* holidays/ups +* holidays/us +* holidays/za diff --git a/lib/holidays/au.rb b/lib/holidays/au.rb index 2644361..36ef0c0 100644 --- a/lib/holidays/au.rb +++ b/lib/holidays/au.rb @@ -1,41 +1,41 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/au.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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_act, :au_nsw, :au_sa, :au_vic] - - HOLIDAYS_BY_MONTH = { - 5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld]}, - {:wday => 1, :week => 1, :name => "May Day", :regions => [:au_nt]}], - 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]}], - 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]}], - 4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]}], - 10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]}] - } - end - - -end - -Holidays.merge_defs(Holidays::AU::DEFINED_REGIONS, Holidays::AU::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/au.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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_act, :au_nsw, :au_sa, :au_vic] + + HOLIDAYS_BY_MONTH = { + 5 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_qld]}, + {:wday => 1, :week => 1, :name => "May Day", :regions => [:au_nt]}], + 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]}], + 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]}], + 4 => [{:mday => 25, :name => "ANZAC Day", :regions => [:au]}], + 10 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:au_act, :au_nsw, :au_sa]}] + } + 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 c625edd..266317d 100644 --- a/lib/holidays/ca.rb +++ b/lib/holidays/ca.rb @@ -1,68 +1,68 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/ca.yaml, data/north_america_informal.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/ca' - # - # More definitions are available at http://code.dunae.ca/holidays. - module CA # :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] - - 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]}], - 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]}], - 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, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :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, :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]}, - {: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, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}], - 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]}], - 4 => [{: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]}] - } - 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 - -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/north_america_informal.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/ca' + # + # More definitions are available at http://code.dunae.ca/holidays. + module CA # :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] + + 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]}], + 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]}], + 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, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :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, :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]}, + {: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, :type => :informal, :name => "St. Patrick's Day", :regions => [:us, :ca]}], + 9 => [{:wday => 1, :week => 1, :name => "Labour Day", :regions => [:ca]}], + 4 => [{: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]}] + } + 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 + +Holidays.merge_defs(Holidays::CA::DEFINED_REGIONS, Holidays::CA::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/de.rb b/lib/holidays/de.rb index 533ed4b..c27b102 100644 --- a/lib/holidays/de.rb +++ b/lib/holidays/de.rb @@ -1,52 +1,52 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/de.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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_sn, :de_he, :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| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :type => :informal, :name => "Ostern", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "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]}, - {: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]}], - 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 => 26, :name => "2. Weihnachtstag", :regions => [:de]}], - 8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by, :de_sl]}], - 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]}] - } - end - -# Germany: Wednesday before November 23 -def self.de_buss_und_bettag(year) - date = Date.civil(year,11,23) - if date.wday > 3 - date -= (date.wday - 3) - else - date -= (date.wday + 4) - end - date -end - - - -end - -Holidays.merge_defs(Holidays::DE::DEFINED_REGIONS, Holidays::DE::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/de.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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_sn, :de_he, :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| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :type => :informal, :name => "Ostern", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "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]}, + {: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]}], + 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 => 26, :name => "2. Weihnachtstag", :regions => [:de]}], + 8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by, :de_sl]}], + 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]}] + } + end + +# Germany: Wednesday before November 23 +def self.de_buss_und_bettag(year) + date = Date.civil(year,11,23) + if date.wday > 3 + date -= (date.wday - 3) + else + date -= (date.wday + 4) + end + date +end + + + +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 index 67e83b1..9e1a4ee 100644 --- a/lib/holidays/dk.rb +++ b/lib/holidays/dk.rb @@ -1,47 +1,47 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/dk.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/dk' - # - # More definitions are available at http://code.dunae.ca/holidays. - module DK # :nodoc: - DEFINED_REGIONS = [:dk] - - HOLIDAYS_BY_MONTH = { - 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]}, - {:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]}], - 0 => [{:function => lambda { |year| 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]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]}], - 11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]}], - 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]}, - {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]}, - {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}], - 1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]}], - 12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]}, - {:mday => 24, :name => "Juleaftensdag", :regions => [:dk]}, - {:mday => 25, :name => "1. juledag", :regions => [:dk]}, - {:mday => 26, :name => "2. juledag", :regions => [:dk]}], - 4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]}, - {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]}, - {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}] - } - end - - -end - -Holidays.merge_defs(Holidays::DK::DEFINED_REGIONS, Holidays::DK::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/dk.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/dk' + # + # More definitions are available at http://code.dunae.ca/holidays. + module DK # :nodoc: + DEFINED_REGIONS = [:dk] + + HOLIDAYS_BY_MONTH = { + 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]}, + {:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]}], + 0 => [{:function => lambda { |year| 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]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]}], + 11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]}], + 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]}, + {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]}, + {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}], + 1 => [{:mday => 1, :name => "Nytårsdag", :regions => [:dk]}], + 12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]}, + {:mday => 24, :name => "Juleaftensdag", :regions => [:dk]}, + {:mday => 25, :name => "1. juledag", :regions => [:dk]}, + {:mday => 26, :name => "2. juledag", :regions => [:dk]}], + 4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]}, + {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]}, + {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}] + } + end + + +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 index e4256c0..dcfbdcd 100644 --- a/lib/holidays/es.rb +++ b/lib/holidays/es.rb @@ -1,52 +1,52 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/es.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Viernes Santo", :regions => [:es]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "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]}] - } - end - - -end - -Holidays.merge_defs(Holidays::ES::DEFINED_REGIONS, Holidays::ES::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/es.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Viernes Santo", :regions => [:es]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "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]}] + } + 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 index 91c85cc..7079018 100644 --- a/lib/holidays/europe.rb +++ b/lib/holidays/europe.rb @@ -1,215 +1,215 @@ -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 - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require '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] - - HOLIDAYS_BY_MONTH = { - 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]}, - {:mday => 5, :type => :informal, :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 => 1, :name => "Verkalýðsdagurinn", :regions => [:is]}, - {:mday => 13, :name => "Mæðradagurinn", :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 => "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]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :type => :informal, :name => "Ostern", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:de]}, - {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th]}, - {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Viernes Santo", :regions => [:es]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lunes de Pascua", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Lundi de Pentecôte", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:gb]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Easter Sunday", :regions => [:gb]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie]}, - {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasqua", :regions => [:it]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lunedì dell'Angelo", :regions => [:it]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinksteren", :regions => [:nl]}, - {: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 => 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]}, - {:mday => 1, :name => "Todos los Santos", :regions => [:es]}, - {:mday => 1, :name => "Toussaint", :regions => [:fr]}, - {:mday => 11, :name => "Armistice 1918", :regions => [:fr]}, - {:mday => 5, :type => :informal, :name => "Guy Fawkes Day", :regions => [:gb]}, - {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}, - {:mday => 1, :name => "Ognissanti", :regions => [:it]}, - {:mday => 1, :name => "Todos os Santos", :regions => [:pt]}], - 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]}, - {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]}, - {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}, - {: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 => "Bank Holiday", :regions => [:ie]}, - {: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]}], - 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, :type => :informal, :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 => "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]}, - {:mday => 26, :name => "2. juledag", :regions => [:dk]}, - {:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]}, - {:mday => 26, :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, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:gb]}, - {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:gb]}, - {:mday => 25, :name => "Christmas Day", :regions => [:ie]}, - {: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, :type => :informal, :name => "Sinterklaas", :regions => [:nl]}, - {:mday => 25, :name => "Kerstmis", :regions => [:nl]}, - {: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]}], - 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, :type => :informal, :name => "Konudagur", :regions => [:is]}], - 8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by, :de_sl]}, - {:mday => 15, :name => "Asunción", :regions => [:es]}, - {:mday => 15, :name => "Assomption", :regions => [:fr]}, - {:wday => 1, :week => 1, :name => "Bank Holiday", :regions => [:gb_sct, :ie]}, - {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]}, - {:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}, - {:mday => 15, :name => "Assunzione", :regions => [:it]}, - {:mday => 15, :name => "Assunção de Nossa Senhora", :regions => [:pt]}], - 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, :type => :informal, :name => "1. april", :regions => [:dk]}, - {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]}, - {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}, - {:mday => 23, :name => "San Jorge", :regions => [:es_ar, :es_cl]}, - {:mday => 23, :name => "Día de Aragón", :regions => [:es_ar]}, - {:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}, - {:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}, - {:mday => 30, :name => "Koninginnedag", :regions => [:nl]}, - {:mday => 25, :name => "Dia da Liberdade", :regions => [:pt]}], - 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 => "Bank Holiday", :regions => [:ie]}, - {:mday => 5, :name => "Implantação da República", :regions => [:pt]}] - } - end - -# Germany: Wednesday before November 23 -def self.de_buss_und_bettag(year) - date = Date.civil(year,11,23) - if date.wday > 3 - date -= (date.wday - 3) - else - date -= (date.wday + 4) - end - date -end - - -# Iceland: first day of summer (Thursday after 18 April) -def self.is_sumardagurinn_fyrsti(year) - date = Date.civil(year,4,18) - if date.wday < 4 - date += (4 - date.wday) - else date - date += (11 - date.wday) - end - date -end - - - -end - -Holidays.merge_defs(Holidays::Europe::DEFINED_REGIONS, Holidays::Europe::HOLIDAYS_BY_MONTH) +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 + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require '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] + + HOLIDAYS_BY_MONTH = { + 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]}, + {:mday => 5, :type => :informal, :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 => 1, :name => "Verkalýðsdagurinn", :regions => [:is]}, + {:mday => 13, :name => "Mæðradagurinn", :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 => "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]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Karfreitag", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :type => :informal, :name => "Ostern", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Ostermontag", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Christi Himmelfahrt", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pfingstmontag", :regions => [:de]}, + {:function => lambda { |year| Holidays.easter(year)+60 }, :function_id => "easter(year)+60", :name => "Fronleichnam", :regions => [:de_bw, :de_by, :de_he, :de_nw, :de_rp, :de_sl, :de_sn, :de_th]}, + {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Jueves Santo", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Viernes Santo", :regions => [:es]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lunes de Pascua", :regions => [:es_pv, :es_ct, :es_na, :es_v, :es_vc]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Lundi de Pentecôte", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:gb]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Easter Sunday", :regions => [:gb]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir, :ie]}, + {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasqua", :regions => [:it]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lunedì dell'Angelo", :regions => [:it]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinksteren", :regions => [:nl]}, + {: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 => 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]}, + {:mday => 1, :name => "Todos los Santos", :regions => [:es]}, + {:mday => 1, :name => "Toussaint", :regions => [:fr]}, + {:mday => 11, :name => "Armistice 1918", :regions => [:fr]}, + {:mday => 5, :type => :informal, :name => "Guy Fawkes Day", :regions => [:gb]}, + {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}, + {:mday => 1, :name => "Ognissanti", :regions => [:it]}, + {:mday => 1, :name => "Todos os Santos", :regions => [:pt]}], + 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]}, + {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]}, + {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}, + {: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 => "Bank Holiday", :regions => [:ie]}, + {: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]}], + 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, :type => :informal, :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 => "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]}, + {:mday => 26, :name => "2. juledag", :regions => [:dk]}, + {:mday => 25, :name => "1. Weihnachtstag", :regions => [:de]}, + {:mday => 26, :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, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:gb]}, + {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Boxing Day", :regions => [:gb]}, + {:mday => 25, :name => "Christmas Day", :regions => [:ie]}, + {: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, :type => :informal, :name => "Sinterklaas", :regions => [:nl]}, + {:mday => 25, :name => "Kerstmis", :regions => [:nl]}, + {: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]}], + 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, :type => :informal, :name => "Konudagur", :regions => [:is]}], + 8 => [{:mday => 15, :name => "Mariä Himmelfahrt", :regions => [:de_by, :de_sl]}, + {:mday => 15, :name => "Asunción", :regions => [:es]}, + {:mday => 15, :name => "Assomption", :regions => [:fr]}, + {:wday => 1, :week => 1, :name => "Bank Holiday", :regions => [:gb_sct, :ie]}, + {:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]}, + {:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}, + {:mday => 15, :name => "Assunzione", :regions => [:it]}, + {:mday => 15, :name => "Assunção de Nossa Senhora", :regions => [:pt]}], + 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, :type => :informal, :name => "1. april", :regions => [:dk]}, + {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]}, + {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}, + {:mday => 23, :name => "San Jorge", :regions => [:es_ar, :es_cl]}, + {:mday => 23, :name => "Día de Aragón", :regions => [:es_ar]}, + {:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}, + {:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}, + {:mday => 30, :name => "Koninginnedag", :regions => [:nl]}, + {:mday => 25, :name => "Dia da Liberdade", :regions => [:pt]}], + 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 => "Bank Holiday", :regions => [:ie]}, + {:mday => 5, :name => "Implantação da República", :regions => [:pt]}] + } + end + +# Germany: Wednesday before November 23 +def self.de_buss_und_bettag(year) + date = Date.civil(year,11,23) + if date.wday > 3 + date -= (date.wday - 3) + else + date -= (date.wday + 4) + end + date +end + + +# Iceland: first day of summer (Thursday after 18 April) +def self.is_sumardagurinn_fyrsti(year) + date = Date.civil(year,4,18) + if date.wday < 4 + date += (4 - date.wday) + else date + date += (11 - date.wday) + end + date +end + + + +end + +Holidays.merge_defs(Holidays::Europe::DEFINED_REGIONS, Holidays::Europe::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/fr.rb b/lib/holidays/fr.rb index 8dcfb52..0b9362a 100644 --- a/lib/holidays/fr.rb +++ b/lib/holidays/fr.rb @@ -1,36 +1,36 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/fr.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:fr]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "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]}] - } - end - - -end - -Holidays.merge_defs(Holidays::FR::DEFINED_REGIONS, Holidays::FR::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/fr.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pâques", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lundi de Pâques", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Ascension", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pentecôte", :regions => [:fr]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "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]}] + } + 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 6237de5..608a7d2 100644 --- a/lib/holidays/gb.rb +++ b/lib/holidays/gb.rb @@ -1,40 +1,40 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/gb.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:gb]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Easter Sunday", :regions => [:gb]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]}], - 11 => [{:mday => 5, :type => :informal, :name => "Guy Fawkes Day", :regions => [:gb]}], - 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:gb]}, - {:mday => 2, :name => "New Year's", :regions => [:gb_sct]}], - 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:gb]}, - {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :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, :gb_nir]}], - 3 => [{:mday => 5, :name => "St. Piran's Day", :regions => [:gb_con]}, - {:mday => 17, :name => "St. Patrick's Day", :regions => [:gb_nir]}] - } - 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 + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:gb]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Easter Sunday", :regions => [:gb]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:gb_eng, :gb_wls, :gb_eaw, :gb_nir]}], + 11 => [{:mday => 5, :type => :informal, :name => "Guy Fawkes Day", :regions => [:gb]}], + 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:gb]}, + {:mday => 2, :name => "New Year's", :regions => [:gb_sct]}], + 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_weekend(date) }, :observed_id => "to_monday_if_weekend", :name => "Christmas Day", :regions => [:gb]}, + {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :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, :gb_nir]}], + 3 => [{:mday => 5, :name => "St. Piran's Day", :regions => [:gb_con]}, + {:mday => 17, :name => "St. Patrick's Day", :regions => [:gb_nir]}] + } + 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 a9b10e5..0d531b6 100644 --- a/lib/holidays/ie.rb +++ b/lib/holidays/ie.rb @@ -1,32 +1,32 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/ie.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:ie]}], - 6 => [{:wday => 1, :week => 1, :name => "Bank Holiday", :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 => "Bank Holiday", :regions => [:ie]}], - 3 => [{:mday => 17, :name => "St. Patrick's Day", :regions => [:ie]}], - 10 => [{:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:ie]}] - } - 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 + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Easter Monday", :regions => [:ie]}], + 6 => [{:wday => 1, :week => 1, :name => "Bank Holiday", :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 => "Bank Holiday", :regions => [:ie]}], + 3 => [{:mday => 17, :name => "St. Patrick's Day", :regions => [:ie]}], + 10 => [{:wday => 1, :week => -1, :name => "Bank Holiday", :regions => [:ie]}] + } + 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 index a96d886..280609a 100644 --- a/lib/holidays/is.rb +++ b/lib/holidays/is.rb @@ -1,61 +1,61 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/is.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/is' - # - # More definitions are available at http://code.dunae.ca/holidays. - module IS # :nodoc: - DEFINED_REGIONS = [:is] - - HOLIDAYS_BY_MONTH = { - 5 => [{:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]}, - {:mday => 13, :name => "Mæðradagurinn", :regions => [:is]}], - 0 => [{:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]}], - 11 => [{:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}], - 6 => [{:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]}, - {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]}], - 1 => [{:mday => 1, :name => "Nýársdagur", :regions => [:is]}, - {:mday => 6, :name => "Þrettándinn", :regions => [:is]}, - {:mday => 19, :type => :informal, :name => "Bóndadagur", :regions => [:is]}], - 12 => [{:mday => 24, :name => "Jól", :regions => [:is]}, - {:mday => 25, :name => "Jól", :regions => [:is]}, - {:mday => 26, :name => "Jól", :regions => [:is]}, - {:mday => 31, :name => "Gamlárskvöld", :regions => [:is]}], - 2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}], - 8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}], - 4 => [{:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}] - } - end - -# Iceland: first day of summer (Thursday after 18 April) -def self.is_sumardagurinn_fyrsti(year) - date = Date.civil(year,4,18) - if date.wday < 4 - date += (4 - date.wday) - else date - date += (11 - date.wday) - end - date -end - - - -end - -Holidays.merge_defs(Holidays::IS::DEFINED_REGIONS, Holidays::IS::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/is.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/is' + # + # More definitions are available at http://code.dunae.ca/holidays. + module IS # :nodoc: + DEFINED_REGIONS = [:is] + + HOLIDAYS_BY_MONTH = { + 5 => [{:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]}, + {:mday => 13, :name => "Mæðradagurinn", :regions => [:is]}], + 0 => [{:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]}], + 11 => [{:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}], + 6 => [{:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]}, + {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]}], + 1 => [{:mday => 1, :name => "Nýársdagur", :regions => [:is]}, + {:mday => 6, :name => "Þrettándinn", :regions => [:is]}, + {:mday => 19, :type => :informal, :name => "Bóndadagur", :regions => [:is]}], + 12 => [{:mday => 24, :name => "Jól", :regions => [:is]}, + {:mday => 25, :name => "Jól", :regions => [:is]}, + {:mday => 26, :name => "Jól", :regions => [:is]}, + {:mday => 31, :name => "Gamlárskvöld", :regions => [:is]}], + 2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}], + 8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}], + 4 => [{:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}] + } + end + +# Iceland: first day of summer (Thursday after 18 April) +def self.is_sumardagurinn_fyrsti(year) + date = Date.civil(year,4,18) + if date.wday < 4 + date += (4 - date.wday) + else date + date += (11 - date.wday) + end + date +end + + + +end + +Holidays.merge_defs(Holidays::IS::DEFINED_REGIONS, Holidays::IS::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/it.rb b/lib/holidays/it.rb index f80e9ff..73eadd4 100644 --- a/lib/holidays/it.rb +++ b/lib/holidays/it.rb @@ -1,35 +1,35 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/it.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/it' - # - # More definitions are available at http://code.dunae.ca/holidays. - module IT # :nodoc: - DEFINED_REGIONS = [:it] - - HOLIDAYS_BY_MONTH = { - 5 => [{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]}], - 0 => [{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasqua", :regions => [:it]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lunedì dell'Angelo", :regions => [:it]}], - 11 => [{:mday => 1, :name => "Ognissanti", :regions => [:it]}], - 6 => [{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]}], - 1 => [{:mday => 1, :name => "Capodanno", :regions => [:it]}, - {:mday => 6, :name => "Epifania", :regions => [:it]}], - 12 => [{:mday => 8, :name => "Immacolata Concezione", :regions => [:it]}, - {:mday => 25, :name => "Natale", :regions => [:it]}, - {:mday => 26, :name => "Santo Stefano", :regions => [:it]}], - 8 => [{:mday => 15, :name => "Assunzione", :regions => [:it]}], - 4 => [{:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}] - } - end - - -end - -Holidays.merge_defs(Holidays::IT::DEFINED_REGIONS, Holidays::IT::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/it.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/it' + # + # More definitions are available at http://code.dunae.ca/holidays. + module IT # :nodoc: + DEFINED_REGIONS = [:it] + + HOLIDAYS_BY_MONTH = { + 5 => [{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]}], + 0 => [{:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasqua", :regions => [:it]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Lunedì dell'Angelo", :regions => [:it]}], + 11 => [{:mday => 1, :name => "Ognissanti", :regions => [:it]}], + 6 => [{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]}], + 1 => [{:mday => 1, :name => "Capodanno", :regions => [:it]}, + {:mday => 6, :name => "Epifania", :regions => [:it]}], + 12 => [{:mday => 8, :name => "Immacolata Concezione", :regions => [:it]}, + {:mday => 25, :name => "Natale", :regions => [:it]}, + {:mday => 26, :name => "Santo Stefano", :regions => [:it]}], + 8 => [{:mday => 15, :name => "Assunzione", :regions => [:it]}], + 4 => [{:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}] + } + end + + +end + +Holidays.merge_defs(Holidays::IT::DEFINED_REGIONS, Holidays::IT::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/mx.rb b/lib/holidays/mx.rb index 8f23f26..c9760da 100644 --- a/lib/holidays/mx.rb +++ b/lib/holidays/mx.rb @@ -1,51 +1,51 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/mx.yaml, data/north_america_informal.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/mx' - # - # More definitions are available at http://code.dunae.ca/holidays. - module MX # :nodoc: - DEFINED_REGIONS = [:mx, :mx_pue, :us, :ca] - - HOLIDAYS_BY_MONTH = { - 5 => [{: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 => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}], - 11 => [{:mday => 1, :type => :informal, :name => "Todos los Santos", :regions => [:mx]}, - {:mday => 2, :type => :informal, :name => "Los Fieles Difuntos", :regions => [:mx]}, - {:wday => 1, :week => 3, :name => "Día de la Revolución", :regions => [:mx]}], - 6 => [{:wday => 0, :week => 3, :type => :informal, :name => "Día del Padre", :regions => [:mx]}], - 1 => [{:mday => 1, :name => "Año nuevo", :regions => [:mx]}, - {:mday => 6, :name => "Dia de los Santos Reyes", :regions => [:mx]}], - 12 => [{:mday => 12, :type => :informal, :name => "Día de la Virgen de Guadalupe", :regions => [:mx]}, - {:mday => 24, :type => :informal, :name => "Nochebuena", :regions => [:mx]}, - {:mday => 25, :name => "Navidad", :regions => [:mx]}, - {:mday => 28, :name => "Los Santos Inocentes", :regions => [:mx]}], - 2 => [{:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]}, - {:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]}, - {:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}], - 3 => [{: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 => [{:mday => 15, :name => "Grito de Dolores", :regions => [:mx]}, - {:mday => 16, :name => "Día de la Independencia", :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 => [{:mday => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]}, - {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}] - } - end - - -end - -Holidays.merge_defs(Holidays::MX::DEFINED_REGIONS, Holidays::MX::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/mx.yaml, data/north_america_informal.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/mx' + # + # More definitions are available at http://code.dunae.ca/holidays. + module MX # :nodoc: + DEFINED_REGIONS = [:mx, :mx_pue, :us, :ca] + + HOLIDAYS_BY_MONTH = { + 5 => [{: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 => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}], + 11 => [{:mday => 1, :type => :informal, :name => "Todos los Santos", :regions => [:mx]}, + {:mday => 2, :type => :informal, :name => "Los Fieles Difuntos", :regions => [:mx]}, + {:wday => 1, :week => 3, :name => "Día de la Revolución", :regions => [:mx]}], + 6 => [{:wday => 0, :week => 3, :type => :informal, :name => "Día del Padre", :regions => [:mx]}], + 1 => [{:mday => 1, :name => "Año nuevo", :regions => [:mx]}, + {:mday => 6, :name => "Dia de los Santos Reyes", :regions => [:mx]}], + 12 => [{:mday => 12, :type => :informal, :name => "Día de la Virgen de Guadalupe", :regions => [:mx]}, + {:mday => 24, :type => :informal, :name => "Nochebuena", :regions => [:mx]}, + {:mday => 25, :name => "Navidad", :regions => [:mx]}, + {:mday => 28, :name => "Los Santos Inocentes", :regions => [:mx]}], + 2 => [{:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]}, + {:mday => 2, :type => :informal, :name => "Groundhog Day", :regions => [:us, :ca]}, + {:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:us, :ca]}], + 3 => [{: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 => [{:mday => 15, :name => "Grito de Dolores", :regions => [:mx]}, + {:mday => 16, :name => "Día de la Independencia", :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 => [{:mday => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]}, + {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}] + } + 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 index 853ee7e..0c6a497 100644 --- a/lib/holidays/nl.rb +++ b/lib/holidays/nl.rb @@ -1,36 +1,36 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/nl.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:nl]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinksteren", :regions => [:nl]}], - 1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]}], - 12 => [{:mday => 5, :type => :informal, :name => "Sinterklaas", :regions => [:nl]}, - {:mday => 25, :name => "Kerstmis", :regions => [:nl]}, - {:mday => 26, :name => "Kerstmis", :regions => [:nl]}], - 4 => [{:mday => 30, :name => "Koninginnedag", :regions => [:nl]}] - } - end - - -end - -Holidays.merge_defs(Holidays::NL::DEFINED_REGIONS, Holidays::NL::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/nl.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Goede Vrijdag", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Pasen", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Pasen", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Hemelvaartsdag", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinksteren", :regions => [:nl]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Pinksteren", :regions => [:nl]}], + 1 => [{:mday => 1, :name => "Nieuwjaar", :regions => [:nl]}], + 12 => [{:mday => 5, :type => :informal, :name => "Sinterklaas", :regions => [:nl]}, + {:mday => 25, :name => "Kerstmis", :regions => [:nl]}, + {:mday => 26, :name => "Kerstmis", :regions => [:nl]}], + 4 => [{:mday => 30, :name => "Koninginnedag", :regions => [:nl]}] + } + 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 d15034b..3ee9562 100644 --- a/lib/holidays/north_america.rb +++ b/lib/holidays/north_america.rb @@ -1,107 +1,107 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # 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: - # - # require '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, :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]}, - {: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 => 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]}], - 11 => [{:mday => 11, :name => "Rememberance Day", :regions => [:ca]}, - {:mday => 1, :type => :informal, :name => "Todos los Santos", :regions => [:mx]}, - {:mday => 2, :type => :informal, :name => "Los Fieles Difuntos", :regions => [:mx]}, - {:wday => 1, :week => 3, :name => "Día de la Revolución", :regions => [:mx]}, - {: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]}], - 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]}, - {:wday => 0, :week => 3, :type => :informal, :name => "Día del Padre", :regions => [:mx]}], - 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca]}, - {:mday => 2, :name => "New Year's", :regions => [:ca_qc]}, - {:mday => 1, :name => "Año nuevo", :regions => [:mx]}, - {:mday => 6, :name => "Dia de los Santos Reyes", :regions => [:mx]}, - {: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, :name => "Christmas Day", :regions => [:ca]}, - {:mday => 26, :name => "Boxing Day", :regions => [:ca]}, - {:mday => 12, :type => :informal, :name => "Día de la Virgen de Guadalupe", :regions => [:mx]}, - {:mday => 24, :type => :informal, :name => "Nochebuena", :regions => [:mx]}, - {:mday => 25, :name => "Navidad", :regions => [:mx]}, - {:mday => 28, :name => "Los Santos Inocentes", :regions => [:mx]}, - {:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}], - 7 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Canada Day", :regions => [:ca]}, - {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]}, - {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]}, - {: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]}, - {:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]}, - {: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]}, - {: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á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 => 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 => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]}, - {:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]}, - {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}] - } - 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 - -Holidays.merge_defs(Holidays::North_America::DEFINED_REGIONS, Holidays::North_America::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # 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: + # + # require '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, :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]}, + {: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 => 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]}], + 11 => [{:mday => 11, :name => "Rememberance Day", :regions => [:ca]}, + {:mday => 1, :type => :informal, :name => "Todos los Santos", :regions => [:mx]}, + {:mday => 2, :type => :informal, :name => "Los Fieles Difuntos", :regions => [:mx]}, + {:wday => 1, :week => 3, :name => "Día de la Revolución", :regions => [:mx]}, + {: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]}], + 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]}, + {:wday => 0, :week => 3, :type => :informal, :name => "Día del Padre", :regions => [:mx]}], + 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:ca]}, + {:mday => 2, :name => "New Year's", :regions => [:ca_qc]}, + {:mday => 1, :name => "Año nuevo", :regions => [:mx]}, + {:mday => 6, :name => "Dia de los Santos Reyes", :regions => [:mx]}, + {: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, :name => "Christmas Day", :regions => [:ca]}, + {:mday => 26, :name => "Boxing Day", :regions => [:ca]}, + {:mday => 12, :type => :informal, :name => "Día de la Virgen de Guadalupe", :regions => [:mx]}, + {:mday => 24, :type => :informal, :name => "Nochebuena", :regions => [:mx]}, + {:mday => 25, :name => "Navidad", :regions => [:mx]}, + {:mday => 28, :name => "Los Santos Inocentes", :regions => [:mx]}, + {:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:us]}], + 7 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Canada Day", :regions => [:ca]}, + {:mday => 12, :name => "Orangemen's Day", :regions => [:ca_nf]}, + {:mday => 9, :name => "Nunavut Day", :regions => [:ca_nu]}, + {: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]}, + {:wday => 1, :week => 1, :name => "Día de la Constitución", :regions => [:mx]}, + {: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]}, + {: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á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 => 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 => 12, :type => :informal, :name => "Día de la Raza", :regions => [:mx]}, + {:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]}, + {:mday => 31, :type => :informal, :name => "Halloween", :regions => [:us, :ca]}] + } + 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 + +Holidays.merge_defs(Holidays::North_America::DEFINED_REGIONS, Holidays::North_America::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/nyse.rb b/lib/holidays/nyse.rb index 9fb819a..c3c54ac 100644 --- a/lib/holidays/nyse.rb +++ b/lib/holidays/nyse.rb @@ -1,32 +1,32 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/nyse.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/nyse' - # - # More definitions are available at http://code.dunae.ca/holidays. - module NYSE # :nodoc: - DEFINED_REGIONS = [:nyse] - - HOLIDAYS_BY_MONTH = { - 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:nyse]}], - 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}], - 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:nyse]}], - 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:nyse]}, - {:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:nyse]}], - 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:nyse]}], - 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:nyse]}], - 2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:nyse]}], - 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:nyse]}] - } - end - - -end - -Holidays.merge_defs(Holidays::NYSE::DEFINED_REGIONS, Holidays::NYSE::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/nyse.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/nyse' + # + # More definitions are available at http://code.dunae.ca/holidays. + module NYSE # :nodoc: + DEFINED_REGIONS = [:nyse] + + HOLIDAYS_BY_MONTH = { + 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:nyse]}], + 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:nyse]}], + 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:nyse]}], + 1 => [{:mday => 1, :name => "New Year's Day", :regions => [:nyse]}, + {:wday => 1, :week => 3, :name => "Martin Luther King, Jr. Day", :regions => [:nyse]}], + 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:nyse]}], + 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:nyse]}], + 2 => [{:wday => 1, :week => 3, :name => "Presidents' Day", :regions => [:nyse]}], + 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:nyse]}] + } + end + + +end + +Holidays.merge_defs(Holidays::NYSE::DEFINED_REGIONS, Holidays::NYSE::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/pt.rb b/lib/holidays/pt.rb index de7ab8e..3f3bab2 100644 --- a/lib/holidays/pt.rb +++ b/lib/holidays/pt.rb @@ -1,52 +1,37 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/se.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/pt' - # - # More definitions are available at http://code.dunae.ca/holidays. - module PT # :nodoc: - DEFINED_REGIONS = [:se] - - HOLIDAYS_BY_MONTH = { - 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 - -Holidays.merge_defs(Holidays::PT::DEFINED_REGIONS, Holidays::PT::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/pt.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/pt' + # + # More definitions are available at http://code.dunae.ca/holidays. + module PT # :nodoc: + DEFINED_REGIONS = [:pt] + + 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]}] + } + end + + +end + +Holidays.merge_defs(Holidays::PT::DEFINED_REGIONS, Holidays::PT::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/scandinavia.rb b/lib/holidays/scandinavia.rb index 7e18a70..d8340ee 100644 --- a/lib/holidays/scandinavia.rb +++ b/lib/holidays/scandinavia.rb @@ -1,114 +1,114 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/dk.yaml, data/is.yaml, data/se.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/scandinavia' - # - # More definitions are available at http://code.dunae.ca/holidays. - module SCANDINAVIA # :nodoc: - DEFINED_REGIONS = [:dk, :is, :se] - - HOLIDAYS_BY_MONTH = { - 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]}, - {:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]}, - {:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]}, - {:mday => 13, :name => "Mæðradagurinn", :regions => [:is]}, - {:mday => 1, :name => "Första maj", :regions => [:se]}], - 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]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]}, - {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]}, - {: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]}], - 11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]}, - {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}], - 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]}, - {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]}, - {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}, - {:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]}, - {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]}, - {: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 => "Nytårsdag", :regions => [:dk]}, - {:mday => 1, :name => "Nýársdagur", :regions => [:is]}, - {:mday => 6, :name => "Þrettándinn", :regions => [:is]}, - {:mday => 19, :type => :informal, :name => "Bóndadagur", :regions => [:is]}, - {:mday => 1, :name => "Nyårsdagen", :regions => [:se]}, - {:mday => 6, :name => "Trettondedag jul", :regions => [:se]}], - 12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]}, - {:mday => 24, :name => "Juleaftensdag", :regions => [:dk]}, - {:mday => 25, :name => "1. juledag", :regions => [:dk]}, - {:mday => 26, :name => "2. juledag", :regions => [:dk]}, - {:mday => 24, :name => "Jól", :regions => [:is]}, - {:mday => 25, :name => "Jól", :regions => [:is]}, - {:mday => 26, :name => "Jól", :regions => [:is]}, - {:mday => 31, :name => "Gamlárskvöld", :regions => [:is]}, - {:mday => 25, :name => "Juldagen", :regions => [:se]}, - {:mday => 26, :name => "Annandag jul", :regions => [:se]}], - 2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}], - 8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}], - 4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]}, - {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]}, - {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}, - {:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}] - } - end - -# Iceland: first day of summer (Thursday after 18 April) -def self.is_sumardagurinn_fyrsti(year) - date = Date.civil(year,4,18) - if date.wday < 4 - date += (4 - date.wday) - else date - date += (11 - date.wday) - end - date -end - - -# 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::SCANDINAVIA::DEFINED_REGIONS, Holidays::SCANDINAVIA::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/dk.yaml, data/is.yaml, data/se.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/scandinavia' + # + # More definitions are available at http://code.dunae.ca/holidays. + module SCANDINAVIA # :nodoc: + DEFINED_REGIONS = [:dk, :is, :se] + + HOLIDAYS_BY_MONTH = { + 5 => [{:mday => 1, :name => "Arbejdernes kampdag", :regions => [:dk]}, + {:mday => 5, :type => :informal, :name => "Danmarks befrielse", :regions => [:dk]}, + {:mday => 1, :name => "Verkalýðsdagurinn", :regions => [:is]}, + {:mday => 13, :name => "Mæðradagurinn", :regions => [:is]}, + {:mday => 1, :name => "Första maj", :regions => [:se]}], + 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]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Langfredag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Påskedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "2. påskedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+26 }, :function_id => "easter(year)+26", :name => "Store Bededag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Kristi Himmelfartsdag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Pinsedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "2. Pinsedag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.easter(year)-48 }, :function_id => "easter(year)-48", :name => "Bolludagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-47 }, :function_id => "easter(year)-47", :name => "Sprengidagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-46 }, :function_id => "easter(year)-46", :name => "Öskudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-7 }, :function_id => "easter(year)-7", :name => "Pálmasunnudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-3 }, :function_id => "easter(year)-3", :name => "Skírdagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Föstudaginn langi", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year) }, :function_id => "easter(year)", :name => "Páskadagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Annar í páskum", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+39 }, :function_id => "easter(year)+39", :name => "Uppstigningardagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+49 }, :function_id => "easter(year)+49", :name => "Hvítasunnudagur", :regions => [:is]}, + {:function => lambda { |year| Holidays.easter(year)+50 }, :function_id => "easter(year)+50", :name => "Annar í hvítasunnu", :regions => [:is]}, + {: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]}], + 11 => [{:mday => 10, :type => :informal, :name => "Mortensaften", :regions => [:dk]}, + {:mday => 16, :name => "Dagur íslenskrar tungu", :regions => [:is]}], + 6 => [{:mday => 5, :name => "Grundlovsdag", :regions => [:dk]}, + {:mday => 15, :type => :informal, :name => "Valdemarsdag og Genforeningsdag", :regions => [:dk]}, + {:mday => 23, :type => :informal, :name => "Sankt Hans aften", :regions => [:dk]}, + {:mday => 3, :type => :informal, :name => "Sjómannadagurinn", :regions => [:is]}, + {:mday => 17, :name => "Lýðveldisdagurinn", :regions => [:is]}, + {: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 => "Nytårsdag", :regions => [:dk]}, + {:mday => 1, :name => "Nýársdagur", :regions => [:is]}, + {:mday => 6, :name => "Þrettándinn", :regions => [:is]}, + {:mday => 19, :type => :informal, :name => "Bóndadagur", :regions => [:is]}, + {:mday => 1, :name => "Nyårsdagen", :regions => [:se]}, + {:mday => 6, :name => "Trettondedag jul", :regions => [:se]}], + 12 => [{:mday => 13, :type => :informal, :name => "Sankt Lucia", :regions => [:dk]}, + {:mday => 24, :name => "Juleaftensdag", :regions => [:dk]}, + {:mday => 25, :name => "1. juledag", :regions => [:dk]}, + {:mday => 26, :name => "2. juledag", :regions => [:dk]}, + {:mday => 24, :name => "Jól", :regions => [:is]}, + {:mday => 25, :name => "Jól", :regions => [:is]}, + {:mday => 26, :name => "Jól", :regions => [:is]}, + {:mday => 31, :name => "Gamlárskvöld", :regions => [:is]}, + {:mday => 25, :name => "Juldagen", :regions => [:se]}, + {:mday => 26, :name => "Annandag jul", :regions => [:se]}], + 2 => [{:mday => 18, :type => :informal, :name => "Konudagur", :regions => [:is]}], + 8 => [{:wday => 1, :week => 1, :name => "Frídagur verslunarmanna", :regions => [:is]}], + 4 => [{:mday => 1, :type => :informal, :name => "1. april", :regions => [:dk]}, + {:mday => 9, :type => :informal, :name => "Danmarks besættelse", :regions => [:dk]}, + {:mday => 16, :type => :informal, :name => "Dronningens fødselsdag", :regions => [:dk]}, + {:function => lambda { |year| Holidays.is_sumardagurinn_fyrsti(year) }, :function_id => "is_sumardagurinn_fyrsti(year)", :name => "Sumardagurinn fyrsti", :regions => [:is]}] + } + end + +# Iceland: first day of summer (Thursday after 18 April) +def self.is_sumardagurinn_fyrsti(year) + date = Date.civil(year,4,18) + if date.wday < 4 + date += (4 - date.wday) + else date + date += (11 - date.wday) + end + date +end + + +# 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::SCANDINAVIA::DEFINED_REGIONS, Holidays::SCANDINAVIA::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/se.rb b/lib/holidays/se.rb index 290fa57..8233a93 100644 --- a/lib/holidays/se.rb +++ b/lib/holidays/se.rb @@ -1,52 +1,52 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/se.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/se' - # - # More definitions are available at http://code.dunae.ca/holidays. - module SE # :nodoc: - DEFINED_REGIONS = [:se] - - HOLIDAYS_BY_MONTH = { - 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 - -Holidays.merge_defs(Holidays::SE::DEFINED_REGIONS, Holidays::SE::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/se.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/se' + # + # More definitions are available at http://code.dunae.ca/holidays. + module SE # :nodoc: + DEFINED_REGIONS = [:se] + + HOLIDAYS_BY_MONTH = { + 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 + +Holidays.merge_defs(Holidays::SE::DEFINED_REGIONS, Holidays::SE::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/united_nations.rb b/lib/holidays/united_nations.rb index b051ac0..cee76ec 100644 --- a/lib/holidays/united_nations.rb +++ b/lib/holidays/united_nations.rb @@ -1,24 +1,24 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/united_nations.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/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) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/united_nations.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/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/ups.rb b/lib/holidays/ups.rb index 26af100..8e1058b 100644 --- a/lib/holidays/ups.rb +++ b/lib/holidays/ups.rb @@ -1,31 +1,31 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/ups.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/ups' - # - # More definitions are available at http://code.dunae.ca/holidays. - module UPS # :nodoc: - DEFINED_REGIONS = [:ups] - - HOLIDAYS_BY_MONTH = { - 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:ups]}], - 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:ups]}, - {:wday => 5, :week => 4, :name => "Day After Thanksgiving", :regions => [:ups]}], - 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:ups]}], - 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:ups]}, - {:mday => 31, :name => "New Year's Eve", :regions => [:ups]}], - 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:ups]}], - 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:ups]}] - } - end - - -end - -Holidays.merge_defs(Holidays::UPS::DEFINED_REGIONS, Holidays::UPS::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/ups.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/ups' + # + # More definitions are available at http://code.dunae.ca/holidays. + module UPS # :nodoc: + DEFINED_REGIONS = [:ups] + + HOLIDAYS_BY_MONTH = { + 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:ups]}], + 11 => [{:wday => 4, :week => 4, :name => "Thanksgiving", :regions => [:ups]}, + {:wday => 5, :week => 4, :name => "Day After Thanksgiving", :regions => [:ups]}], + 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "New Year's Day", :regions => [:ups]}], + 12 => [{:mday => 25, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Christmas Day", :regions => [:ups]}, + {:mday => 31, :name => "New Year's Eve", :regions => [:ups]}], + 7 => [{:mday => 4, :observed => lambda { |date| Holidays.to_weekday_if_weekend(date) }, :observed_id => "to_weekday_if_weekend", :name => "Independence Day", :regions => [:ups]}], + 9 => [{:wday => 1, :week => 1, :name => "Labor Day", :regions => [:ups]}] + } + end + + +end + +Holidays.merge_defs(Holidays::UPS::DEFINED_REGIONS, Holidays::UPS::HOLIDAYS_BY_MONTH) diff --git a/lib/holidays/us.rb b/lib/holidays/us.rb index 73dd331..8d59763 100644 --- a/lib/holidays/us.rb +++ b/lib/holidays/us.rb @@ -1,48 +1,48 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/us.yaml, data/north_america_informal.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/us' - # - # More definitions are available at http://code.dunae.ca/holidays. - module US # :nodoc: - DEFINED_REGIONS = [:us, :us_dc, :ca] - - HOLIDAYS_BY_MONTH = { - 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]}, - {:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}], - 0 => [{:function => lambda { |year| 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]}, - {: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]}, - {:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}], - 10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]}, - {: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 - -Holidays.merge_defs(Holidays::US::DEFINED_REGIONS, Holidays::US::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/us.yaml, data/north_america_informal.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/us' + # + # More definitions are available at http://code.dunae.ca/holidays. + module US # :nodoc: + DEFINED_REGIONS = [:us, :us_dc, :ca] + + HOLIDAYS_BY_MONTH = { + 5 => [{:wday => 1, :week => -1, :name => "Memorial Day", :regions => [:us]}, + {:wday => 0, :week => 3, :type => :informal, :name => "Father's Day", :regions => [:us, :ca]}], + 0 => [{:function => lambda { |year| 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]}, + {: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]}, + {:mday => 22, :type => :informal, :name => "Earth Day", :regions => [:us, :ca]}], + 10 => [{:wday => 1, :week => 2, :name => "Columbus Day", :regions => [:us]}, + {: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 + +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 b2b8aed..9bc2eb3 100644 --- a/lib/holidays/za.rb +++ b/lib/holidays/za.rb @@ -1,35 +1,35 @@ -module Holidays - # This file is generated by the Ruby Holiday gem. - # - # Definitions loaded: data/za.yaml - # - # To use the definitions in this file, load them right after you load the - # Holiday gem: - # - # require 'holidays' - # require 'holidays/za' - # - # More definitions are available at http://code.dunae.ca/holidays. - module ZA # :nodoc: - DEFINED_REGIONS = [:za] - - HOLIDAYS_BY_MONTH = { - 5 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Workers Day", :regions => [:za]}], - 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:za]}, - {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Family Day", :regions => [:za]}], - 6 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Youth Day", :regions => [:za]}], - 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "New Year's Day", :regions => [:za]}], - 12 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Day of Reconciliation", :regions => [:za]}, - {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Christmas Day", :regions => [:za]}, - {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Day of Goodwill", :regions => [:za]}], - 8 => [{:mday => 9, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "National Women's Day", :regions => [:za]}], - 3 => [{:mday => 21, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Human Rights Day", :regions => [:za]}], - 9 => [{:mday => 24, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Heritage Day", :regions => [:za]}], - 4 => [{:mday => 27, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Freedom Day", :regions => [:za]}] - } - end - - -end - -Holidays.merge_defs(Holidays::ZA::DEFINED_REGIONS, Holidays::ZA::HOLIDAYS_BY_MONTH) +module Holidays + # This file is generated by the Ruby Holiday gem. + # + # Definitions loaded: data/za.yaml + # + # To use the definitions in this file, load them right after you load the + # Holiday gem: + # + # require 'holidays' + # require 'holidays/za' + # + # More definitions are available at http://code.dunae.ca/holidays. + module ZA # :nodoc: + DEFINED_REGIONS = [:za] + + HOLIDAYS_BY_MONTH = { + 5 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Workers Day", :regions => [:za]}], + 0 => [{:function => lambda { |year| Holidays.easter(year)-2 }, :function_id => "easter(year)-2", :name => "Good Friday", :regions => [:za]}, + {:function => lambda { |year| Holidays.easter(year)+1 }, :function_id => "easter(year)+1", :name => "Family Day", :regions => [:za]}], + 6 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Youth Day", :regions => [:za]}], + 1 => [{:mday => 1, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "New Year's Day", :regions => [:za]}], + 12 => [{:mday => 16, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Day of Reconciliation", :regions => [:za]}, + {:mday => 25, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Christmas Day", :regions => [:za]}, + {:mday => 26, :observed => lambda { |date| Holidays.to_weekday_if_boxing_weekend(date) }, :observed_id => "to_weekday_if_boxing_weekend", :name => "Day of Goodwill", :regions => [:za]}], + 8 => [{:mday => 9, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "National Women's Day", :regions => [:za]}], + 3 => [{:mday => 21, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Human Rights Day", :regions => [:za]}], + 9 => [{:mday => 24, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Heritage Day", :regions => [:za]}], + 4 => [{:mday => 27, :observed => lambda { |date| Holidays.to_monday_if_sunday(date) }, :observed_id => "to_monday_if_sunday", :name => "Freedom Day", :regions => [:za]}] + } + end + + +end + +Holidays.merge_defs(Holidays::ZA::DEFINED_REGIONS, Holidays::ZA::HOLIDAYS_BY_MONTH) diff --git a/test/defs/test_defs_au.rb b/test/defs/test_defs_au.rb index 3152724..a9af891 100644 --- a/test/defs/test_defs_au.rb +++ b/test/defs/test_defs_au.rb @@ -1,36 +1,36 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/au' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/au.yaml -class AuDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/au' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/au.yaml +class AuDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 diff --git a/test/defs/test_defs_ca.rb b/test/defs/test_defs_ca.rb index 050bee0..664c107 100644 --- a/test/defs/test_defs_ca.rb +++ b/test/defs/test_defs_ca.rb @@ -1,29 +1,29 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/ca' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/ca.yaml, data/north_america_informal.yaml -class CaDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/ca' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/ca.yaml, data/north_america_informal.yaml +class CaDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_de.rb b/test/defs/test_defs_de.rb index cf7ce4e..6825dde 100644 --- a/test/defs/test_defs_de.rb +++ b/test/defs/test_defs_de.rb @@ -1,46 +1,46 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/de' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/de.yaml -class DeDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/de' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/de.yaml +class DeDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_dk.rb b/test/defs/test_defs_dk.rb index 843205d..5515006 100644 --- a/test/defs/test_defs_dk.rb +++ b/test/defs/test_defs_dk.rb @@ -1,30 +1,30 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/dk' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/dk.yaml -class DkDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/dk' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/dk.yaml +class DkDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_es.rb b/test/defs/test_defs_es.rb index 0f7c658..24c2185 100644 --- a/test/defs/test_defs_es.rb +++ b/test/defs/test_defs_es.rb @@ -1,57 +1,57 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/es' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/es.yaml -class EsDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/es' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/es.yaml +class EsDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_europe.rb b/test/defs/test_defs_europe.rb index ebd960b..a43edd0 100644 --- a/test/defs/test_defs_europe.rb +++ b/test/defs/test_defs_europe.rb @@ -1,240 +1,240 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/europe' - -# 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 -class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_europe -{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 - -{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] - - -{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] - -{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 - -{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 - -{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 - -{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 - -{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 - -{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 - -{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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/europe' + +# 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 +class EuropeDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_europe +{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 + +{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] + + +{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] + +{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 + +{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 + +{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 + +{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 + +{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 + +{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 + +{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 +end diff --git a/test/defs/test_defs_fr.rb b/test/defs/test_defs_fr.rb index 9b7d4e9..a3ca364 100644 --- a/test/defs/test_defs_fr.rb +++ b/test/defs/test_defs_fr.rb @@ -1,26 +1,26 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/fr' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/fr.yaml -class FrDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/fr' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/fr.yaml +class FrDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_gb.rb b/test/defs/test_defs_gb.rb index a1664d7..565a2c9 100644 --- a/test/defs/test_defs_gb.rb +++ b/test/defs/test_defs_gb.rb @@ -1,36 +1,36 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/gb' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/gb.yaml -class GbDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_gb -{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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/gb' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/gb.yaml +class GbDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_gb +{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 +end diff --git a/test/defs/test_defs_ie.rb b/test/defs/test_defs_ie.rb index 2f4ce73..5391547 100644 --- a/test/defs/test_defs_ie.rb +++ b/test/defs/test_defs_ie.rb @@ -1,21 +1,21 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/ie' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/ie.yaml -class IeDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/ie' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/ie.yaml +class IeDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_is.rb b/test/defs/test_defs_is.rb index 854ba05..a3ee66f 100644 --- a/test/defs/test_defs_is.rb +++ b/test/defs/test_defs_is.rb @@ -1,33 +1,33 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/is' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/is.yaml -class IsDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/is' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/is.yaml +class IsDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_it.rb b/test/defs/test_defs_it.rb index 4956412..49a6b26 100644 --- a/test/defs/test_defs_it.rb +++ b/test/defs/test_defs_it.rb @@ -1,25 +1,25 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/it' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/it.yaml -class ItDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/it' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/it.yaml +class ItDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_mx.rb b/test/defs/test_defs_mx.rb index 262d13b..d3eef11 100644 --- a/test/defs/test_defs_mx.rb +++ b/test/defs/test_defs_mx.rb @@ -1,22 +1,22 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/mx' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/mx.yaml, data/north_america_informal.yaml -class MxDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/mx' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/mx.yaml, data/north_america_informal.yaml +class MxDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_nl.rb b/test/defs/test_defs_nl.rb index f828fa9..67aaabe 100644 --- a/test/defs/test_defs_nl.rb +++ b/test/defs/test_defs_nl.rb @@ -1,24 +1,24 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/nl' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/nl.yaml -class NlDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/nl' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/nl.yaml +class NlDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_north_america.rb b/test/defs/test_defs_north_america.rb index 6ae27f8..508189d 100644 --- a/test/defs/test_defs_north_america.rb +++ b/test/defs/test_defs_north_america.rb @@ -1,54 +1,54 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/north_america' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/north_america_informal.yaml -class North_americaDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_north_america -{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 - -{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 - -{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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/north_america' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/ca.yaml, data/mx.yaml, data/us.yaml, data/north_america_informal.yaml +class North_americaDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_north_america +{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 + +{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 + +{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 diff --git a/test/defs/test_defs_nyse.rb b/test/defs/test_defs_nyse.rb index f7c4157..76cf37f 100644 --- a/test/defs/test_defs_nyse.rb +++ b/test/defs/test_defs_nyse.rb @@ -1,22 +1,22 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/nyse' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/nyse.yaml -class NyseDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_nyse -{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,3,21) => 'Good Friday', - Date.civil(2008,5,26) => 'Memorial Day', - Date.civil(2008,7,4) => 'Independence Day', - Date.civil(2008,9,1) => 'Labor Day', - Date.civil(2008,11,27) => 'Thanksgiving', - Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name| - assert_equal name, Holidays.on(date, :nyse)[0][:name] -end - end -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/nyse' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/nyse.yaml +class NyseDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_nyse +{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,3,21) => 'Good Friday', + Date.civil(2008,5,26) => 'Memorial Day', + Date.civil(2008,7,4) => 'Independence Day', + Date.civil(2008,9,1) => 'Labor Day', + Date.civil(2008,11,27) => 'Thanksgiving', + Date.civil(2008,12,25) => 'Christmas Day'}.each do |date, name| + assert_equal name, Holidays.on(date, :nyse)[0][:name] +end + end +end diff --git a/test/defs/test_defs_pt.rb b/test/defs/test_defs_pt.rb index a248e5b..0a3ee20 100644 --- a/test/defs/test_defs_pt.rb +++ b/test/defs/test_defs_pt.rb @@ -1,32 +1,32 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/pt' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/se.yaml -class PtDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_pt -{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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/pt' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/pt.yaml +class PtDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 +end diff --git a/test/defs/test_defs_scandinavia.rb b/test/defs/test_defs_scandinavia.rb index 68512a2..106556a 100644 --- a/test/defs/test_defs_scandinavia.rb +++ b/test/defs/test_defs_scandinavia.rb @@ -1,75 +1,75 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/scandinavia' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/dk.yaml, data/is.yaml, data/se.yaml -class ScandinaviaDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_scandinavia -{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 - -{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 - -{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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/scandinavia' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/dk.yaml, data/is.yaml, data/se.yaml +class ScandinaviaDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_scandinavia +{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 + +{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 + +{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 diff --git a/test/defs/test_defs_se.rb b/test/defs/test_defs_se.rb index 9beb260..6dd005a 100644 --- a/test/defs/test_defs_se.rb +++ b/test/defs/test_defs_se.rb @@ -1,32 +1,32 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/se' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/se.yaml -class SeDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/se' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/se.yaml +class SeDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 diff --git a/test/defs/test_defs_ups.rb b/test/defs/test_defs_ups.rb index 0138ca1..c77390c 100644 --- a/test/defs/test_defs_ups.rb +++ b/test/defs/test_defs_ups.rb @@ -1,21 +1,21 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/ups' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/ups.yaml -class UpsDefinitionTests < Test::Unit::TestCase # :nodoc: - - def test_ups -{Date.civil(2008,1,1) => 'New Year\'s 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,11,27) => 'Thanksgiving', - Date.civil(2008,11,28) => 'Day After Thanksgiving', - Date.civil(2008,12,25) => 'Christmas Day', - Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name| - assert_equal name, Holidays.on(date, :ups)[0][:name] -end - end -end +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/ups' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/ups.yaml +class UpsDefinitionTests < Test::Unit::TestCase # :nodoc: + + def test_ups +{Date.civil(2008,1,1) => 'New Year\'s 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,11,27) => 'Thanksgiving', + Date.civil(2008,11,28) => 'Day After Thanksgiving', + Date.civil(2008,12,25) => 'Christmas Day', + Date.civil(2008,12,31) => 'New Year\'s Eve',}.each do |date, name| + assert_equal name, Holidays.on(date, :ups)[0][:name] +end + end +end diff --git a/test/defs/test_defs_us.rb b/test/defs/test_defs_us.rb index 7b3ff96..0c4b527 100644 --- a/test/defs/test_defs_us.rb +++ b/test/defs/test_defs_us.rb @@ -1,23 +1,23 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/us' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/us.yaml, data/north_america_informal.yaml -class UsDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/us' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/us.yaml, data/north_america_informal.yaml +class UsDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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 diff --git a/test/defs/test_defs_za.rb b/test/defs/test_defs_za.rb index 4cc3aa0..db9f476 100644 --- a/test/defs/test_defs_za.rb +++ b/test/defs/test_defs_za.rb @@ -1,25 +1,25 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'holidays/za' - -# This file is generated by the Ruby Holiday gem. -# -# Definitions loaded: data/za.yaml -class ZaDefinitionTests < Test::Unit::TestCase # :nodoc: - - 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 +require File.dirname(__FILE__) + '/../test_helper' +require 'holidays/za' + +# This file is generated by the Ruby Holiday gem. +# +# Definitions loaded: data/za.yaml +class ZaDefinitionTests < Test::Unit::TestCase # :nodoc: + + 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