diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2008-02-10 17:02:22 +0000 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2008-02-10 17:02:22 +0000 |
commit | 94fa9fb74541b60ed04f2694558a6a98a9ce1cab (patch) | |
tree | b615ef44b629aae80daef6a66ac5bb9b4e52e03d | |
parent | 2c8fb682cb6dfe889b31bbb76c90de5011aec009 (diff) | |
download | rails-94fa9fb74541b60ed04f2694558a6a98a9ce1cab.tar.gz rails-94fa9fb74541b60ed04f2694558a6a98a9ce1cab.tar.bz2 rails-94fa9fb74541b60ed04f2694558a6a98a9ce1cab.zip |
TimeZone#new renamed #local, so that new TimeWithZone instances can be created via Time.zone.local()
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8847 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 2 | ||||
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/values/time_zone.rb | 6 | ||||
-rw-r--r-- | activesupport/test/time_zone_test.rb | 4 |
5 files changed, 10 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 1fd8cbd722..b45d6e3373 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Base#instantiate_time_object uses Time.zone.local() [Geoff Buesing] + * Add timezone-aware attribute readers and writers. #10982 [Geoff Buesing] * Instantiating time objects in multiparameter attributes uses Time.zone if available. #10982 [rick] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index fc45930d73..f273c04a94 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2475,7 +2475,7 @@ module ActiveRecord #:nodoc: # Includes an ugly hack for Time.local instead of Time.new because the latter is reserved by Time itself. def instantiate_time_object(name, values) if Time.zone && !self.class.skip_time_zone_conversion_for_attributes.include?(name.to_sym) - Time.zone.new(*values) + Time.zone.local(*values) else @@default_timezone == :utc ? Time.utc(*values) : Time.local(*values) end diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index 38294ebef7..6b66875012 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* TimeZone#new method renamed #local; when used with Time.zone, constructor now reads: Time.zone.local() [Geoff Buesing] + * Added Base64.encode64s to encode values in base64 without the newlines. This makes the values immediately usable as URL parameters or memcache keys without further processing [DHH] * Remove :nodoc: entries around the ActiveSupport test/unit assertions. #10946 [dancroak, jamesh] diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index fed64579e4..4f2fc5e44b 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -177,9 +177,9 @@ class TimeZone # Method for creating new ActiveSupport::TimeWithZone instance in time zone of self. Example: # - # Time.zone = "Hawaii" # => "Hawaii" - # Time.zone.new(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00 - def new(*args) + # Time.zone = "Hawaii" # => "Hawaii" + # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00 + def local(*args) Time.utc_time(*args).change_time_zone(self) end diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index cd3972a41c..43f60690d9 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -129,8 +129,8 @@ class TimeZoneTest < Test::Unit::TestCase assert !TimeZone.us_zones.include?(TimeZone["Kuala Lumpur"]) end - def test_new - time = TimeZone["Hawaii"].new(2007, 2, 5, 15, 30, 45) + def test_local + time = TimeZone["Hawaii"].local(2007, 2, 5, 15, 30, 45) assert_equal Time.utc(2007, 2, 5, 15, 30, 45), time.time assert_equal TimeZone["Hawaii"], time.time_zone end |