method
make_time
make_time(date, year, yday, mon, day, hour, min, sec, sec_fraction, zone, now)
private
Hide source
# File lib/time.rb, line 192 def make_time(date, year, yday, mon, day, hour, min, sec, sec_fraction, zone, now) if !year && !yday && !mon && !day && !hour && !min && !sec && !sec_fraction raise ArgumentError, "no time information in #{date.inspect}" end off = nil if year || now off_year = year || now.year off = zone_offset(zone, off_year) if zone end if yday unless (1..366) === yday raise ArgumentError, "yday #{yday} out of range" end mon, day = (yday-1).divmod(31) mon += 1 day += 1 t = make_time(date, year, nil, mon, day, hour, min, sec, sec_fraction, zone, now) diff = yday - t.yday return t if diff.zero? day += diff if day > 28 and day > (mday = month_days(off_year, mon)) if (mon += 1) > 12 raise ArgumentError, "yday #{yday} out of range" end day -= mday end return make_time(date, year, nil, mon, day, hour, min, sec, sec_fraction, zone, now) end if now and now.respond_to?(:getlocal) if off now = now.getlocal(off) if now.utc_offset != off else now = now.getlocal end end usec = nil usec = sec_fraction * 1000000 if sec_fraction if now begin break if year; year = now.year break if mon; mon = now.mon break if day; day = now.day break if hour; hour = now.hour break if min; min = now.min break if sec; sec = now.sec break if sec_fraction; usec = now.tv_usec end until true end year ||= 1970 mon ||= 1 day ||= 1 hour ||= 0 min ||= 0 sec ||= 0 usec ||= 0 if year != off_year off = nil off = zone_offset(zone, year) if zone end if off year, mon, day, hour, min, sec = apply_offset(year, mon, day, hour, min, sec, off) t = self.utc(year, mon, day, hour, min, sec, usec) force_zone!(t, zone, off) t else self.local(year, mon, day, hour, min, sec, usec) end end