Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/hackapp_gem.rb
Instance Method Summary collapse
-
#change_timezone(options) ⇒ Object
adjust according to what you want to view.
-
#to_UTC ⇒ Object
times in database are eastern time to add 5 hours to all.
Instance Method Details
#change_timezone(options) ⇒ Object
adjust according to what you want to view
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hackapp_gem.rb', line 17 def change_timezone() zones = {"eastern" => -5, "central" => -6, "mountain" => -7, "arizona" => -7, "pacific" => -8, "alaska" => -9, "aleutian" => -10, "hawaiian" => -11} if Time.new.zone == "EST" zones = {"eastern" => -4, "central" => -5, "mountain" => -6, "arizona" => -6, "pacific" => -7, "alaska" => -8, "aleutian" => -9, "hawaiian" => -10} if Time.new.zone == "EDT" begin end_zone_offset = zones[[:new_timezone]] # to_UTC is called because the times in db are already eastern self.to_UTC.to_datetime.advance(:hours => end_zone_offset).to_datetime rescue Exception => e puts "Unrecognizeable timezone: #{e}" end end |
#to_UTC ⇒ Object
times in database are eastern time to add 5 hours to all
6 7 8 9 10 11 12 13 14 |
# File 'lib/hackapp_gem.rb', line 6 def to_UTC begin shift_to_UTC = 5 if Time.new.zone == "EST" shift_to_UTC = 4 if Time.new.zone == "EDT" self.to_datetime.advance(:hours => shift_to_UTC).to_datetime rescue Exception => e puts "Unrecognizeable timezone: #{e}" end end |