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 |
# 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} 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
7 8 9 10 11 12 13 14 |
# File 'lib/hackapp_gem.rb', line 7 def to_UTC begin shift_to_UTC = 5 self.to_datetime.advance(:hours => shift_to_UTC).to_datetime rescue Exception => e puts "Unrecognizeable timezone: #{e}" end end |