Method: IceCube::TimeUtil::TimeWrapper#add

Defined in:
lib/ice_cube/time_util.rb

#add(type, val) ⇒ Object

DST-safely add an interval of time to the wrapped time



286
287
288
289
290
291
292
293
294
295
296
# File 'lib/ice_cube/time_util.rb', line 286

def add(type, val)
  type = :day if type == :wday
  @time += case type
  when :year then TimeUtil.days_in_n_years(@time, val) * ONE_DAY
  when :month then TimeUtil.days_in_n_months(@time, val) * ONE_DAY
  when :day then val * ONE_DAY
  when :hour then val * ONE_HOUR
  when :min then val * ONE_MINUTE
  when :sec then val
  end
end