diff options
author | Brian Morearty <github2@morearty.org> | 2011-02-04 09:10:07 -0800 |
---|---|---|
committer | Brian Morearty <github2@morearty.org> | 2011-02-04 09:10:07 -0800 |
commit | 3a29bfae2cbb956e469942ed1d4ea8c702085a1a (patch) | |
tree | 68af11c7b252df538739203d8cafc8353409b515 /activesupport/lib/active_support/core_ext | |
parent | ac15647bf0e6ed85714dee4e2b14b2e7e6f29320 (diff) | |
download | rails-3a29bfae2cbb956e469942ed1d4ea8c702085a1a.tar.gz rails-3a29bfae2cbb956e469942ed1d4ea8c702085a1a.tar.bz2 rails-3a29bfae2cbb956e469942ed1d4ea8c702085a1a.zip |
Change Time.zone= docs.
Update the example to show how to reset the current thread's
Time.zone upon exiting a request.
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/zones.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/zones.rb b/activesupport/lib/active_support/core_ext/time/zones.rb index ef401a6d18..ff90d7ca58 100644 --- a/activesupport/lib/active_support/core_ext/time/zones.rb +++ b/activesupport/lib/active_support/core_ext/time/zones.rb @@ -19,14 +19,18 @@ class Time # * A TZInfo::Timezone object. # * An identifier for a TZInfo::Timezone object (e.g., "America/New_York"). # - # Here's an example of how you might set <tt>Time.zone</tt> on a per request basis -- <tt>current_user.time_zone</tt> - # just needs to return a string identifying the user's preferred TimeZone: + # Here's an example of how you might set <tt>Time.zone</tt> on a per request basis and reset it when the request is done. + # <tt>current_user.time_zone</tt> just needs to return a string identifying the user's preferred time zone: # # class ApplicationController < ActionController::Base - # before_filter :set_time_zone + # around_filter :set_time_zone # # def set_time_zone - # Time.zone = current_user.time_zone + # old_time_zone = Time.zone + # Time.zone = current_user.time_zone if logged_in? + # yield + # ensure + # Time.zone = old_time_zone # end # end def zone=(time_zone) |