Class: Feriados::Rules::Easter
- Inherits:
-
Object
- Object
- Feriados::Rules::Easter
- Defined in:
- lib/feriados/rules/easter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(year) ⇒ Easter
constructor
A new instance of Easter.
Constructor Details
#initialize(year) ⇒ Easter
Returns a new instance of Easter.
4 5 6 |
# File 'lib/feriados/rules/easter.rb', line 4 def initialize(year) @year = year end |
Class Method Details
Instance Method Details
#date ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/feriados/rules/easter.rb', line 8 def date a = year % 19 b = year / 100 c = year % 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 result = h + l - 7 * m + 114 month = result / 31 day = (result % 31) + 1 Date.new(year, month, day) end |