Class: ActiveSupport::TimeWithZone
- Inherits:
-
Object
- Object
- ActiveSupport::TimeWithZone
- Defined in:
- lib/hackapp_gem.rb
Instance Method Summary collapse
Instance Method Details
#change_timezone(options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/hackapp_gem.rb', line 5 def change_timezone() zones = {"eastern" => -5, "central" => -6, "mountain" => -7, "arizona" => -7, "pacific" => -8, "alaska" => -9, "aleutian" => -10, "hawaiian" => -11} begin end_zone_offset = zones[[:new_timezone]] newhour = end_zone_offset self.to_datetime.advance(:hours => newhour).to_datetime #something not updating here??? rescue Exception => e puts "Unrecognizeable timezone: #{e}" end end |
#change_to_UTC(options) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/hackapp_gem.rb', line 23 def change_to_UTC() begin self.to_datetime.advance(:hours => -5).to_datetime rescue Exception => e puts "Unrecognizeable timezone: #{e}" end end |