class TimeMath::Units::Month
@private
Public Class Methods
new()
click to toggle source
Calls superclass method
TimeMath::Units::Base::new
# File lib/time_math/units/month.rb, line 5 def initialize super(:month) end
Protected Instance Methods
_advance(tm, steps)
click to toggle source
# File lib/time_math/units/month.rb, line 18 def _advance(tm, steps) target = tm.month + steps.to_i m = (target - 1) % 12 + 1 dy = (target - 1) / 12 Util.merge(tm, year: tm.year + dy, month: m) end
_decrease(tm, steps)
click to toggle source
# File lib/time_math/units/month.rb, line 25 def _decrease(tm, steps) _advance(tm, -steps) end
_measure(from, to)
click to toggle source
# File lib/time_math/units/month.rb, line 11 def _measure(from, to) ydiff = to.year - from.year mdiff = to.month - from.month to.day >= from.day ? (ydiff * 12 + mdiff) : (ydiff * 12 + mdiff - 1) end