Class: Time
Overview
Extend Time to allow conversion to DateTime instances
Instance Method Summary collapse
-
#to_datetime ⇒ DateTime
Convert to a DateTime instance stackoverflow.com/a/279785/123695.
Instance Method Details
#to_datetime ⇒ DateTime
Convert to a DateTime instance stackoverflow.com/a/279785/123695
323 324 325 326 327 328 329 330 331 |
# File 'lib/nose/util.rb', line 323 def to_datetime # Convert seconds + microseconds into a fractional number of seconds seconds = sec + Rational(usec, 10**6) # Convert a UTC offset measured in minutes to one measured in a # fraction of a day. offset = Rational(utc_offset, 60 * 60 * 24) DateTime.new(year, month, day, hour, min, seconds, offset) end |