Class: Time

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

Instance Method Summary collapse

Instance Method Details

#convert_time_zone(to_zone) ⇒ Object

Useful but not thread safe!!!!



3
4
5
6
7
8
9
10
# File 'lib/time_zone_hack.rb', line 3

def convert_time_zone(to_zone)
  original_zone = ENV["TZ"]
  utc_time = dup.gmtime
  ENV["TZ"] = to_zone
  to_zone_time = utc_time.localtime
  ENV["TZ"] = original_zone
  return to_zone_time
end