apply_offset(year, mon, day, hour, min, sec, off)
private
Hide source
# File lib/time.rb, line 208 def apply_offset(year, mon, day, hour, min, sec, off) if off < 0 off = -off off, o = off.divmod(60) if o != 0 then sec += o; o, sec = sec.divmod(60); off += o end off, o = off.divmod(60) if o != 0 then min += o; o, min = min.divmod(60); off += o end off, o = off.divmod(24) if o != 0 then hour += o; o, hour = hour.divmod(24); off += o end if off != 0 day += off days = month_days(year, mon) if days and days < day mon += 1 if 12 < mon mon = 1 year += 1 end day = 1 end end elsif 0 < off off, o = off.divmod(60) if o != 0 then sec -= o; o, sec = sec.divmod(60); off -= o end off, o = off.divmod(60) if o != 0 then min -= o; o, min = min.divmod(60); off -= o end off, o = off.divmod(24) if o != 0 then hour -= o; o, hour = hour.divmod(24); off -= o end if off != 0 then day -= off if day < 1 mon -= 1 if mon < 1 year -= 1 mon = 12 end day = month_days(year, mon) end end end return year, mon, day, hour, min, sec end