Class: DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/stalkr/datetime_patch.rb

Overview

monkey patch DateTime to add to_time (exists in Ruby 1.9.2 and above)

Instance Method Summary collapse

Instance Method Details

#to_timeObject



5
6
7
8
9
10
11
12
# File 'lib/stalkr/datetime_patch.rb', line 5

def to_time
  d = new_offset(0)
  t = d.instance_eval do
    Time.utc(year, mon, mday, hour, min, sec +
             sec_fraction)
  end
  t.getlocal
end