Module: CopticEaster

Defined in:
lib/coptic_easter.rb

Class Method Summary collapse

Class Method Details

.calculate_easter_date(greg_year) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/coptic_easter.rb', line 5

def self.calculate_easter_date(greg_year)
  # This function calculates easter date for a Gregorian year
  days_to_add = (((greg_year % 19) *19) + 24) % 30

  easter_date = Date.new(greg_year, 3, 21) + days_to_add

  if easter_date < Date.new(greg_year, 3, 31)
    easter_date += 34
  else
    easter_date += 4
  end

  begin
    easter_date += 1
  end while !easter_date.sunday?
  return easter_date
end