Module: LunarCalendar::Utils
- Defined in:
- lib/lunar_calendar/utils.rb
Overview
The calculate utils
Class Method Summary collapse
-
.decode(data, length, shift) ⇒ Number
Extract packed informactio.
-
.new_year_at(offset) ⇒ LunarCalendar::Solar
Extract lunar new year in solar date.
Class Method Details
.decode(data, length, shift) ⇒ Number
Extract packed informactio
17 18 19 |
# File 'lib/lunar_calendar/utils.rb', line 17 def self.decode(data, length, shift) (data & (((1 << length) - 1) << shift)) >> shift end |
.new_year_at(offset) ⇒ LunarCalendar::Solar
Extract lunar new year in solar date
28 29 30 31 32 33 34 35 |
# File 'lib/lunar_calendar/utils.rb', line 28 def self.new_year_at(offset) solar = LunarCalendar::Data::NEW_YEARS[offset] year = decode(solar, 12, 9) month = decode(solar, 4, 5) day = decode(solar, 5, 0) Solar.new(year, month, day) end |