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