Method: TZInfo::TimeWithOffset#to_datetime
- Defined in:
- lib/tzinfo/time_with_offset.rb
#to_datetime ⇒ DateTime
An overridden version of Time#to_datetime that, if there is an
associated TZInfo::TimezoneOffset, returns a DateTimeWithOffset with that
offset.
135 136 137 138 139 140 141 142 |
# File 'lib/tzinfo/time_with_offset.rb', line 135 def to_datetime if_timezone_offset(super) do |o,dt| offset = dt.offset result = DateTimeWithOffset.jd(dt.jd + dt.day_fraction - offset) result = result.new_offset(offset) unless offset == 0 result.set_timezone_offset(o) end end |