Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/supplement/date.rb,
lib/supplement/date.rb

Constant Summary collapse

EASTER =
"Easter"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.easter_western(year) ⇒ Object Also known as: easter



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/supplement/date.rb', line 21

def easter_western year
  # This is after Donald E. Knuth and it works for both
  # Julian (1582 and before) and Gregorian (1583 and after) calendars.
  g = year%19 + 1                   # golden number
  c = year/100 + 1                  # century
  x = (3*c/4) - 12                  # corrections
  z = (8*c+5)/25 - 5
  d = 5*year/4 - x - 10             # March((-d)%7)th is Sunday
  e = (11*g + 20 + z - x) % 30      # moon phase
  e += 1 if e == 25 and g > 11 or e == 24
  n = 44 - e                        # full moon
  n += 30 if n < 21
  month = 3
  day = n+7 - (d+n)%7
  if day > 31 then
    month +=  1
    day   -= 31
  end
  civil year, month, day
end

Instance Method Details

#dObject



12
# File 'lib/supplement/date.rb', line 12

def d ; day   ; end

#mObject



11
# File 'lib/supplement/date.rb', line 11

def m ; month ; end

#to_aObject



14
# File 'lib/supplement/date.rb', line 14

def to_a ; [ year, month, day ] ; end

#to_dateObject



69
# File 'lib/supplement/date.rb', line 69

def to_date     ; self ; end

#to_datetimeObject



70
# File 'lib/supplement/date.rb', line 70

def to_datetime ; DateTime.new! Date.jd_to_ajd(jd,0,0), @of, @sg ; end

#to_timeObject



68
# File 'lib/supplement/date.rb', line 68

def to_time     ; Time.local year, mon, mday ; end

#yObject



10
# File 'lib/supplement/date.rb', line 10

def y ; year  ; end