Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/timesteps/time.rb

Instance Method Summary collapse

Instance Method Details

#to_datetimeObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/timesteps/time.rb', line 4

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