Class: Holidays::DateCalculator::Easter::Julian
- Inherits:
-
Object
- Object
- Holidays::DateCalculator::Easter::Julian
- Defined in:
- lib/holidays/date_calculator/easter.rb
Instance Method Summary collapse
-
#calculate_easter_for(year) ⇒ Object
Copied from github.com/Loyolny/when_easter Graciously allowed by Michał Nierebiński (github.com/Loyolny).
- #calculate_orthodox_easter_for(year) ⇒ Object
Instance Method Details
#calculate_easter_for(year) ⇒ Object
Copied from github.com/Loyolny/when_easter Graciously allowed by Michał Nierebiński (github.com/Loyolny)
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# 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) ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# 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 |