Module: TimezoneAware::Helpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/timezone-aware/helpers.rb
Instance Method Summary collapse
-
#set_time_zone ⇒ Object
Note, this is not thread safe.
-
#user_time_zone ⇒ Object
Gets timezone.
Instance Method Details
#set_time_zone ⇒ Object
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_zone ⇒ Object
Gets timezone
8 9 10 |
# File 'lib/timezone-aware/helpers.rb', line 8 def user_time_zone ActiveSupport::TimeZone[[:time_zone]] if [:time_zone] end |