This commit is contained in:
parent
e88aae4755
commit
7f3c9b6b88
7 changed files with 408 additions and 1 deletions
|
@ -29,4 +29,3 @@ methods:
|
||||||
day = ((h + l - 7 * m + 114) % 31) + 1
|
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||||
Date.civil(year, month, day)
|
Date.civil(year, month, day)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
100
data/dk.yaml
Normal file
100
data/dk.yaml
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
# Danish holiday definitions for the Ruby Holiday gem.
|
||||||
|
#
|
||||||
|
# Updated: 2008-11-22.
|
||||||
|
# Sources:
|
||||||
|
# - http://en.wikipedia.org/wiki/Holidays_in_Denmark
|
||||||
|
# - http://www.amblondon.um.dk/en/menu/AboutDenmark/PublicHolidaysInDK/PublicHolidaysinDenmark-until2010.htm
|
||||||
|
# - http://borger.dk/forside/kirke-og-tro/folkekirken/officielle-helligdage
|
||||||
|
---
|
||||||
|
months:
|
||||||
|
0:
|
||||||
|
- name: Fastelavn
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)-49 }
|
||||||
|
type: informal
|
||||||
|
- name: Palmesøndag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)-7 }
|
||||||
|
- name: Skærtorsdag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)-3 }
|
||||||
|
- name: Langfredag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)-2 }
|
||||||
|
- name: Påskedag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year) }
|
||||||
|
- name: 2. påskedag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)+1 }
|
||||||
|
- name: Store Bededag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)+26 }
|
||||||
|
- name: Kristi Himmelfartsdag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)+40 }
|
||||||
|
- name: Kristi Himmelfartsdag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)+40 }
|
||||||
|
- name: 2. Pinsedag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)+49 }
|
||||||
|
- name: Pinsedag
|
||||||
|
regions: [dk]
|
||||||
|
function: lambda { |year| easter(year)+50 }
|
||||||
|
1:
|
||||||
|
- name: Nytårsdag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 1
|
||||||
|
4:
|
||||||
|
- name: 1. april
|
||||||
|
regions: [dk]
|
||||||
|
mday: 1
|
||||||
|
type: informal
|
||||||
|
- name: Danmarks besættelse
|
||||||
|
regions: [dk]
|
||||||
|
mday: 9
|
||||||
|
type: informal
|
||||||
|
- name: Dronningens fødselsdag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 16
|
||||||
|
type: informal
|
||||||
|
5:
|
||||||
|
- name: Arbejdernes kampdag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 1
|
||||||
|
- name: Danmarks befrielse
|
||||||
|
regions: [dk]
|
||||||
|
mday: 5
|
||||||
|
type: informal
|
||||||
|
6:
|
||||||
|
- name: Grundlovsdag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 5
|
||||||
|
- name: Valdemarsdag og Genforeningsdag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 15
|
||||||
|
type: informal
|
||||||
|
- name: Sankt Hans aften
|
||||||
|
regions: [dk]
|
||||||
|
mday: 23
|
||||||
|
type: informal
|
||||||
|
11:
|
||||||
|
- name: Mortensaften
|
||||||
|
regions: [dk]
|
||||||
|
mday: 10
|
||||||
|
type: informal
|
||||||
|
12:
|
||||||
|
- name: Sankt Lucia
|
||||||
|
regions: [dk]
|
||||||
|
mday: 13
|
||||||
|
type: informal
|
||||||
|
- name: Juleaftensdag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 24
|
||||||
|
- name: 1. juledag
|
||||||
|
regions: [dk]
|
||||||
|
mday: 25
|
||||||
|
- name: 2. juledag
|
||||||
|
regions: [dk_]
|
||||||
|
mday: 26
|
110
data/es.yaml
Normal file
110
data/es.yaml
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
# Spanish holiday definitions for the Ruby Holiday gem.
|
||||||
|
#
|
||||||
|
# Updated: 2008-11-22.
|
||||||
|
# Sources:
|
||||||
|
# - http://en.wikipedia.org/wiki/Public_holidays_in_Spain
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - Valencia is encoded as both es_v and es_vc
|
||||||
|
---
|
||||||
|
months:
|
||||||
|
0:
|
||||||
|
- name: Jueves Santo
|
||||||
|
regions: [es_pv, es_ct, es_na, es_v, es_vc]
|
||||||
|
function: lambda { |year| easter(year)-3 }
|
||||||
|
- name: Viernes Santo
|
||||||
|
regions: [es]
|
||||||
|
function: lambda { |year| easter(year)-2 }
|
||||||
|
- name: Lunes de Pascua
|
||||||
|
regions: [es_pv, es_ct, es_na, es_v, es_vc]
|
||||||
|
function: lambda { |year| easter(year)+1 }
|
||||||
|
1:
|
||||||
|
- name: Año Nuevo
|
||||||
|
regions: [es]
|
||||||
|
mday: 1
|
||||||
|
- name: Día de Reyes
|
||||||
|
regions: [es]
|
||||||
|
mday: 6
|
||||||
|
2:
|
||||||
|
- name: Día de Andalucía
|
||||||
|
regions: [es_an]
|
||||||
|
mday: 28
|
||||||
|
3:
|
||||||
|
- name: Día de las Islas Baleares
|
||||||
|
regions: [es_ib]
|
||||||
|
mday: 1
|
||||||
|
- name: San José
|
||||||
|
regions: [es_v, es_vc, es_cm, es_mu, es_m]
|
||||||
|
mday: 19
|
||||||
|
4:
|
||||||
|
- name: San Jorge
|
||||||
|
regions: [es_ar, es_cl]
|
||||||
|
mday: 23
|
||||||
|
- name: Día de Aragón
|
||||||
|
regions: [es_ar]
|
||||||
|
mday: 23
|
||||||
|
5:
|
||||||
|
- name: Día del Trabajador
|
||||||
|
regions: [es]
|
||||||
|
mday: 1
|
||||||
|
- name: Fiesta de la Comunidad
|
||||||
|
regions: [es_m]
|
||||||
|
mday: 2
|
||||||
|
- name: Día de las Canarias
|
||||||
|
regions: [es_cn]
|
||||||
|
mday: 30
|
||||||
|
- name: Día de la Región Castilla-La Mancha
|
||||||
|
regions: [es_cm]
|
||||||
|
mday: 31
|
||||||
|
6:
|
||||||
|
- name: Día de la Región de Murcia
|
||||||
|
regions: [es_mu]
|
||||||
|
mday: 9
|
||||||
|
- name: Día de La Rioja
|
||||||
|
regions: [es_lo]
|
||||||
|
mday: 9
|
||||||
|
7:
|
||||||
|
- name: Santiago Apostol
|
||||||
|
regions: [es_ga]
|
||||||
|
mday: 23
|
||||||
|
8:
|
||||||
|
- name: Asunción
|
||||||
|
regions: [es]
|
||||||
|
mday: 15
|
||||||
|
9:
|
||||||
|
- name: Día de Ceuta
|
||||||
|
regions: [es_ce]
|
||||||
|
mday: 2
|
||||||
|
- name: Día de Asturias
|
||||||
|
regions: [es_o]
|
||||||
|
mday: 8
|
||||||
|
- name: Día de Extremadura
|
||||||
|
regions: [es_ex]
|
||||||
|
mday: 8
|
||||||
|
- name: Fiesta Nacional de Cataluña
|
||||||
|
regions: [es_ct]
|
||||||
|
mday: 11
|
||||||
|
10:
|
||||||
|
- name: Día de Valencia
|
||||||
|
regions: [es_vc, es_v]
|
||||||
|
mday: 9
|
||||||
|
- name: Día de la Hispanidad
|
||||||
|
regions: [es]
|
||||||
|
mday: 12
|
||||||
|
11:
|
||||||
|
- name: Todos los Santos
|
||||||
|
regions: [es]
|
||||||
|
mday: 1
|
||||||
|
12:
|
||||||
|
- name: Día de la Constitución
|
||||||
|
regions: [es]
|
||||||
|
mday: 6
|
||||||
|
- name: Inmaculada Concepción
|
||||||
|
regions: [es]
|
||||||
|
mday: 8
|
||||||
|
- name: Navidad del Señor
|
||||||
|
regions: [es]
|
||||||
|
mday: 25
|
||||||
|
- name: San Esteban
|
||||||
|
regions: [es_ib, es_ct]
|
||||||
|
mday: 26
|
51
data/fr.yaml
Normal file
51
data/fr.yaml
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# French holiday definitions for the Ruby Holiday gem.
|
||||||
|
#
|
||||||
|
# Updated: 2008-11-22.
|
||||||
|
# Sources:
|
||||||
|
# - http://en.wikipedia.org/wiki/Holidays_in_France
|
||||||
|
---
|
||||||
|
months:
|
||||||
|
0:
|
||||||
|
- name: Pâques
|
||||||
|
regions: [fr]
|
||||||
|
function: lambda { |year| easter(year) }
|
||||||
|
- name: Ascension
|
||||||
|
regions: [fr]
|
||||||
|
function: lambda { |year| easter(year)+40 }
|
||||||
|
- name: Pentecôte
|
||||||
|
regions: [fr]
|
||||||
|
function: lambda { |year| easter(year)+49 }
|
||||||
|
- name: Lundi de Pentecôte
|
||||||
|
regions: [fr]
|
||||||
|
function: lambda { |year| easter(year)+50 }
|
||||||
|
1:
|
||||||
|
- name: Jour de l'an
|
||||||
|
regions: [fr]
|
||||||
|
mday: 1
|
||||||
|
5:
|
||||||
|
- name: Fête du travail
|
||||||
|
regions: [fr]
|
||||||
|
mday: 1
|
||||||
|
- name: Victoire 1945
|
||||||
|
regions: [fr]
|
||||||
|
mday: 8
|
||||||
|
7:
|
||||||
|
- name: Fête nationale
|
||||||
|
regions: [fr]
|
||||||
|
mday: 14
|
||||||
|
8:
|
||||||
|
- name: Assomption
|
||||||
|
regions: [fr]
|
||||||
|
mday: 15
|
||||||
|
11:
|
||||||
|
- name: Toussaint
|
||||||
|
regions: [fr]
|
||||||
|
mday: 1
|
||||||
|
- name: Armistice 1918
|
||||||
|
regions: [fr]
|
||||||
|
mday: 11
|
||||||
|
12:
|
||||||
|
- name: Noël
|
||||||
|
regions: [fr]
|
||||||
|
mday: 25
|
||||||
|
|
67
data/is.yaml
Normal file
67
data/is.yaml
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
# Islandic holiday definitions for the Ruby Holiday gem.
|
||||||
|
#
|
||||||
|
# Updated: 2008-11-22.
|
||||||
|
# Sources:
|
||||||
|
# - http://www.iceland.is/history-and-culture/Traditions/IcelandicHolidays/
|
||||||
|
# - http://en.wikipedia.org/wiki/Public_holidays_in_Iceland
|
||||||
|
---
|
||||||
|
months:
|
||||||
|
0:
|
||||||
|
- name: Fastelavn
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)-49 }
|
||||||
|
type: informal
|
||||||
|
- name: Palmesøndag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)-7 }
|
||||||
|
- name: Skærtorsdag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)-3 }
|
||||||
|
- name: Langfredag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)-2 }
|
||||||
|
- name: Påskedag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year) }
|
||||||
|
- name: 2. påskedag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)+1 }
|
||||||
|
- name: Store Bededag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)+26 }
|
||||||
|
- name: Kristi Himmelfartsdag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)+40 }
|
||||||
|
- name: Kristi Himmelfartsdag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)+40 }
|
||||||
|
- name: 2. Pinsedag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)+49 }
|
||||||
|
- name: Pinsedag
|
||||||
|
regions: [is]
|
||||||
|
function: lambda { |year| easter(year)+50 }
|
||||||
|
1:
|
||||||
|
- name: Nýársdagur
|
||||||
|
regions: [is]
|
||||||
|
mday: 1
|
||||||
|
- name: Þrettándinn
|
||||||
|
regions: [is]
|
||||||
|
mday: 6
|
||||||
|
- name: Bóndadagur
|
||||||
|
regions: [is]
|
||||||
|
mday: 19
|
||||||
|
type: informal
|
||||||
|
2:
|
||||||
|
- name: Konudagur
|
||||||
|
regions: [is]
|
||||||
|
mday: 18
|
||||||
|
type: informal
|
||||||
|
5:
|
||||||
|
- name: Verkalýðsdagurinn
|
||||||
|
regions: [is]
|
||||||
|
mday: 1
|
||||||
|
- name: Mæðradagurinn
|
||||||
|
regions: [is]
|
||||||
|
mday: 13
|
||||||
|
|
80
lib/holidays/za.rb
Normal file
80
lib/holidays/za.rb
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
module Holidays
|
||||||
|
# This file is generated by the Ruby Holiday gem.
|
||||||
|
#
|
||||||
|
# Definitions loaded: data/za.yaml, data/common_methods.yaml
|
||||||
|
#
|
||||||
|
# To use the definitions in the file, load them right after you load the
|
||||||
|
# Holiday gem:
|
||||||
|
#
|
||||||
|
# require 'holidays'
|
||||||
|
# require 'path/to/za'
|
||||||
|
#
|
||||||
|
# More definitions are available at http://code.dunae.ca/holidays.
|
||||||
|
module ZA # :nodoc:
|
||||||
|
DEFINED_REGIONS = [:za]
|
||||||
|
|
||||||
|
HOLIDAYS_BY_MONTH = {
|
||||||
|
5 => [{:mday => 1, :name => "Workers' Day", :regions => [:za]}],
|
||||||
|
0 => [{:function => lambda { |year| easter(year)-2 }, :name => "Good Friday", :regions => [:za]},
|
||||||
|
{:function => lambda { |year| easter(year)+1 }, :name => "Family Day", :regions => [:za]}],
|
||||||
|
6 => [{:mday => 16, :name => "Youth Day", :regions => [:za]}],
|
||||||
|
1 => [{:mday => 1, :name => "New Year's Day", :regions => [:za]}],
|
||||||
|
12 => [{:mday => 16, :name => "Day of Reconciliation", :regions => [:za]},
|
||||||
|
{:mday => 25, :name => "Christmas Day", :regions => [:za]},
|
||||||
|
{:mday => 26, :name => "Day of Goodwill", :regions => [:za]}],
|
||||||
|
8 => [{:mday => 9, :name => "National Women's Day", :regions => [:za]}],
|
||||||
|
3 => [{:mday => 21, :name => "Human Rights Day", :regions => [:za]}],
|
||||||
|
9 => [{:mday => 24, :name => "Heritage Day", :regions => [:za]}],
|
||||||
|
4 => [{:mday => 27, :name => "Freedom Day", :regions => [:za]}]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the date of Easter in a given year.
|
||||||
|
#
|
||||||
|
# +year+ must be a valid Gregorian year.
|
||||||
|
#
|
||||||
|
# Returns a Date object.
|
||||||
|
#--
|
||||||
|
# from http://snippets.dzone.com/posts/show/765
|
||||||
|
# TODO: check year to ensure Gregorian
|
||||||
|
def self.easter(year)
|
||||||
|
y = year
|
||||||
|
a = y % 19
|
||||||
|
b = y / 100
|
||||||
|
c = y % 100
|
||||||
|
d = b / 4
|
||||||
|
e = b % 4
|
||||||
|
f = (b + 8) / 25
|
||||||
|
g = (b - f + 1) / 3
|
||||||
|
h = (19 * a + b - d - g + 15) % 30
|
||||||
|
i = c / 4
|
||||||
|
k = c % 4
|
||||||
|
l = (32 + 2 * e + 2 * i - h - k) % 7
|
||||||
|
m = (a + 11 * h + 22 * l) / 451
|
||||||
|
month = (h + l - 7 * m + 114) / 31
|
||||||
|
day = ((h + l - 7 * m + 114) % 31) + 1
|
||||||
|
Date.civil(year, month, day)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Holidays.class_eval do
|
||||||
|
existing_regions = []
|
||||||
|
if const_defined?(:DEFINED_REGIONS)
|
||||||
|
existing_regions = const_get(:DEFINED_REGIONS)
|
||||||
|
remove_const(:DEFINED_REGIONS)
|
||||||
|
end
|
||||||
|
const_set(:DEFINED_REGIONS, existing_regions | Holidays::ZA::DEFINED_REGIONS)
|
||||||
|
|
||||||
|
existing_defs = {}
|
||||||
|
if const_defined?(:HOLIDAYS_BY_MONTH)
|
||||||
|
existing_defs = const_get(:HOLIDAYS_BY_MONTH)
|
||||||
|
remove_const(:HOLIDAYS_BY_MONTH)
|
||||||
|
end
|
||||||
|
#const_set(:HOLIDAYS_BY_MONTH, existing_defs.merge(Holidays::ZA::HOLIDAYS_BY_MONTH))
|
||||||
|
const_set(:HOLIDAYS_BY_MONTH, Holidays::ZA::HOLIDAYS_BY_MONTH)
|
||||||
|
|
||||||
|
include Holidays::ZA
|
||||||
|
end
|
Loading…
Reference in a new issue