Class: LunarCalendar::Solar

Inherits:
Date
  • Object
show all
Defined in:
lib/lunar_calendar/solar.rb

Overview

The Solar Calendar Date

Instance Attribute Summary

Attributes inherited from Date

#day, #month, #year

Instance Method Summary collapse

Methods inherited from Date

#<=>, #==, #binary, #initialize

Constructor Details

This class inherits a constructor from LunarCalendar::Date

Instance Method Details

#to_iNumber

rubocop:disable Metrics/AbcSize

Returns:

  • (Number)

    solar days

Since:

  • 0.1.0



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lunar_calendar/solar.rb', line 20

def to_i
  m = (@month + 9) % 12
  y = @year - (m / 10)

  (365 * y) + #  One year have 365 days
    (y / 4) - # Add leap days
    (y / 100) +
    (y / 400) +
    ((m * 306 + 5) / 10) + # Unknown
    (@day - 1)
end

#to_lunarLunarCalendar::Lunar

Returns the lunar date.

Returns:

Since:

  • 0.1.0



12
13
14
# File 'lib/lunar_calendar/solar.rb', line 12

def to_lunar
  LunarCalendar::Calculator::Lunar.new(self).perform
end