class Holidays::DateCalculator::Easter::Julian
Public Instance Methods
calculate_easter_for(year)
click to toggle source
Copied from github.com/Loyolny/when_easter Graciously allowed by Michał Nierebiński (github.com/Loyolny)
# File lib/holidays/date_calculator/easter.rb, line 50 def calculate_easter_for(year) g = year % 19 + 1 s = (year - 1600) / 100 - (year - 1600) / 400 l = (((year - 1400) / 100) * 8) / 25 p_2 = (3 - 11 * g + s - l) % 30 if p_2 == 29 || (p_2 == 28 && g > 11) p = p_2 - 1 else p = p_2 end d= (year + year / 4 - year / 100 + year / 400) % 7 d_2 = (8 - d) % 7 p_3 = (80 + p) % 7 x_2 = d_2 - p_3 x = (x_2 - 1) % 7 + 1 e = p+x if e < 11 Date.civil(year,3,e + 21) else Date.civil(year,4,e - 10) end end
calculate_orthodox_easter_for(year)
click to toggle source
# File lib/holidays/date_calculator/easter.rb, line 78 def calculate_orthodox_easter_for(year) y = year g = y % 19 i = (19 * g + 15) % 30 j = (year + year/4 + i) % 7 j_month = 3 + (i - j + 40) / 44 j_day = i - j + 28 - 31 * (j_month / 4) Date.civil(year, j_month, j_day) end