Module: TimezoneAware::Helpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/timezone-aware/helpers.rb

Instance Method Summary collapse

Instance Method Details

#set_time_zoneObject

Note, this is not thread safe



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/timezone-aware/helpers.rb', line 13

def set_time_zone
  old_time_zone = Time.zone

  new_time_zone = user_time_zone()
  
  Time.zone = new_time_zone if new_time_zone

  yield
ensure # make sure we restore old time zone
  Time.zone = old_time_zone
end

#user_time_zoneObject

Gets timezone



8
9
10
# File 'lib/timezone-aware/helpers.rb', line 8

def user_time_zone
  ActiveSupport::TimeZone[cookies[:time_zone]] if cookies[:time_zone]
end