Alex Dunae 2007-11-24 21:22:49 +00:00
parent 2e17c2a9ec
commit f55f4a0023
1 changed files with 63 additions and 63 deletions

View File

@ -1,63 +1,63 @@
module Holidays
# This file is generated by the Ruby Holiday gem.
#
# Definitions loaded: data/it.yaml, data/common_methods.yaml
#
# To use the definitions in the file, load them right after you load the
# Holiday gem:
#
# require 'holidays'
# require 'path/to/it'
#
# More definitions are available at http://code.dunae.ca/holidays.
module IT # :nodoc:
DEFINED_REGIONS = [:it]
HOLIDAYS_BY_MONTH = {
5 => [{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]}],
0 => [{:function => lambda { |year| easter(year) }, :name => "Pasqua", :regions => [:it]},
{:function => lambda { |year| easter(year)+1 }, :name => "Lunedì dell'Angelo", :regions => [:it]}],
11 => [{:mday => 1, :name => "Ognissanti", :regions => [:it]}],
6 => [{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]}],
1 => [{:mday => 1, :name => "Capodanno", :regions => [:it]},
{:mday => 6, :name => "Epifania", :regions => [:it]}],
12 => [{:mday => 8, :name => "Immacolata Concezione", :regions => [:it]},
{:mday => 25, :name => "Natale", :regions => [:it]},
{:mday => 26, :name => "Santo Stefano", :regions => [:it]}],
8 => [{:mday => 15, :name => "Assunzione", :regions => [:it]}],
4 => [{:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}]
}
# Get the date of Easter in a given year.
#
# +year+ must be a valid Gregorian year.
#
# Returns a Date object.
#--
# from http://snippets.dzone.com/posts/show/765
# TODO: check year to ensure Gregorian
def self.easter(year)
y = year
a = y % 19
b = y / 100
c = y % 100
d = b / 4
e = b % 4
f = (b + 8) / 25
g = (b - f + 1) / 3
h = (19 * a + b - d - g + 15) % 30
i = c / 4
k = c % 4
l = (32 + 2 * e + 2 * i - h - k) % 7
m = (a + 11 * h + 22 * l) / 451
month = (h + l - 7 * m + 114) / 31
day = ((h + l - 7 * m + 114) % 31) + 1
Date.civil(year, month, day)
end
end
end
Holidays.merge_defs(Holidays::IT::DEFINED_REGIONS, Holidays::IT::HOLIDAYS_BY_MONTH)
module Holidays
# This file is generated by the Ruby Holiday gem.
#
# Definitions loaded: data/it.yaml, data/common_methods.yaml
#
# To use the definitions in the file, load them right after you load the
# Holiday gem:
#
# require 'holidays'
# require 'path/to/it'
#
# More definitions are available at http://code.dunae.ca/holidays.
module IT # :nodoc:
DEFINED_REGIONS = [:it]
HOLIDAYS_BY_MONTH = {
5 => [{:mday => 1, :name => "Festa dei Lavoratori", :regions => [:it]}],
0 => [{:function => lambda { |year| easter(year) }, :name => "Pasqua", :regions => [:it]},
{:function => lambda { |year| easter(year)+1 }, :name => "Lunedì dell'Angelo", :regions => [:it]}],
11 => [{:mday => 1, :name => "Ognissanti", :regions => [:it]}],
6 => [{:mday => 2, :name => "Festa della Repubblica", :regions => [:it]}],
1 => [{:mday => 1, :name => "Capodanno", :regions => [:it]},
{:mday => 6, :name => "Epifania", :regions => [:it]}],
12 => [{:mday => 8, :name => "Immacolata Concezione", :regions => [:it]},
{:mday => 25, :name => "Natale", :regions => [:it]},
{:mday => 26, :name => "Santo Stefano", :regions => [:it]}],
8 => [{:mday => 15, :name => "Assunzione", :regions => [:it]}],
4 => [{:mday => 25, :name => "Festa della Liberazione", :regions => [:it]}]
}
# Get the date of Easter in a given year.
#
# +year+ must be a valid Gregorian year.
#
# Returns a Date object.
#--
# from http://snippets.dzone.com/posts/show/765
# TODO: check year to ensure Gregorian
def self.easter(year)
y = year
a = y % 19
b = y / 100
c = y % 100
d = b / 4
e = b % 4
f = (b + 8) / 25
g = (b - f + 1) / 3
h = (19 * a + b - d - g + 15) % 30
i = c / 4
k = c % 4
l = (32 + 2 * e + 2 * i - h - k) % 7
m = (a + 11 * h + 22 * l) / 451
month = (h + l - 7 * m + 114) / 31
day = ((h + l - 7 * m + 114) % 31) + 1
Date.civil(year, month, day)
end
end
end
Holidays.merge_defs(Holidays::IT::DEFINED_REGIONS, Holidays::IT::HOLIDAYS_BY_MONTH)