diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2008-01-23 20:49:53 +0000 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2008-01-23 20:49:53 +0000 |
commit | 213fac6f49532e7ee08348542e80465088b9bf5d (patch) | |
tree | 955a7643f4559bf23cb20f00dfa0215c60ddaa72 /activesupport/lib | |
parent | cb8de22dfb7a6dd5cb5bdca0d38ae797925e89d7 (diff) | |
download | rails-213fac6f49532e7ee08348542e80465088b9bf5d.tar.gz rails-213fac6f49532e7ee08348542e80465088b9bf5d.tar.bz2 rails-213fac6f49532e7ee08348542e80465088b9bf5d.zip |
TimeZone#now returns an ActiveSupport::TimeWithZone
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8710 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 689ba5a6e5..7adc8133c6 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -177,22 +177,27 @@ class TimeZone begin # the following methods depend on the tzinfo gem require_library_or_gem "tzinfo" unless Object.const_defined?(:TZInfo) - # Compute and return the current time, in the time zone represented by - # +self+. + # Returns an ActiveSupport::TimeWithZone instance representing the current time + # in the time zone represented by +self+. Example: + # + # Time.zone = 'Hawaii' # => "Hawaii" + # Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00 def now - tzinfo.now + tzinfo.now.change_time_zone(self) end # Return the current date in this time zone. def today - now.to_date + tzinfo.now.to_date end - # Adjust the given time to the time zone represented by +self+. + # Adjust the given time to the simultaneous time in the time zone represented by +self+. Returns a + # Time.utc() instance -- if you want an ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead. def utc_to_local(time) tzinfo.utc_to_local(time) end - + + # Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance. def local_to_utc(time, dst=true) tzinfo.local_to_utc(time, dst) end |