64 lines
2.1 KiB
Ruby
64 lines
2.1 KiB
Ruby
|
module Holidays
|
||
|
# This file is generated by the Ruby Holiday gem.
|
||
|
#
|
||
|
# Definitions loaded: data/fr.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/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| easter(year) }, :name => "Pâques", :regions => [:fr]},
|
||
|
{:function => lambda { |year| easter(year)+40 }, :name => "Ascension", :regions => [:fr]},
|
||
|
{:function => lambda { |year| easter(year)+49 }, :name => "Pentecôte", :regions => [:fr]},
|
||
|
{:function => lambda { |year| 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]}]
|
||
|
}
|
||
|
|
||
|
# 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::FR::DEFINED_REGIONS, Holidays::FR::HOLIDAYS_BY_MONTH)
|