diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-13 20:28:55 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-10-13 20:28:55 +0000 |
commit | f0448f5631288e3b73f9c95ebc1870dd54967a87 (patch) | |
tree | 16f700a80c148bd3d1cadd2279e81781cc326b6c | |
parent | 43b6a74fb188e41ae686c2d948e876c1f84e7bdf (diff) | |
download | rails-f0448f5631288e3b73f9c95ebc1870dd54967a87.tar.gz rails-f0448f5631288e3b73f9c95ebc1870dd54967a87.tar.bz2 rails-f0448f5631288e3b73f9c95ebc1870dd54967a87.zip |
Fixed that Time#change should also reset usec when also resetting minutes #2459 [ikeda@dream.big.or.jp]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2568 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activesupport/CHANGELOG | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/time_ext_test.rb | 5 |
3 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index d43011b9b8..12614f3460 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that Time#change should also reset usec when also resetting minutes #2459 [ikeda@dream.big.or.jp] + * Fix Logger compatibility for distributions that don't keep Ruby and its standard library in sync. * Replace '%e' from long and short time formats as Windows does not support it. #2344. [Tom Ward <tom@popdog.net>] diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 451be56599..85cd318a22 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -41,7 +41,7 @@ module ActiveSupport #:nodoc: options[:hour] || self.hour, options[:min] || (options[:hour] ? 0 : self.min), options[:sec] || ((options[:hour] || options[:min]) ? 0 : self.sec), - options[:usec] || ((options[:hour] || options[:min] || options[:usec]) ? 0 : self.usec) + options[:usec] || ((options[:hour] || options[:min] || options[:sec]) ? 0 : self.usec) ) end diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 86f8b7e4f6..0119c92c93 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -100,6 +100,11 @@ class TimeExtCalculationsTest < Test::Unit::TestCase assert_equal Time.local(2005,2,22,16), Time.local(2005,2,22,15,15,10).change(:hour => 16) assert_equal Time.local(2005,2,22,16,45), Time.local(2005,2,22,15,15,10).change(:hour => 16, :min => 45) assert_equal Time.local(2005,2,22,15,45), Time.local(2005,2,22,15,15,10).change(:min => 45) + + assert_equal Time.local(2005,1,2, 5, 0, 0, 0), Time.local(2005,1,2,11,22,33,44).change(:hour => 5) + assert_equal Time.local(2005,1,2,11, 6, 0, 0), Time.local(2005,1,2,11,22,33,44).change(:min => 6) + assert_equal Time.local(2005,1,2,11,22, 7, 0), Time.local(2005,1,2,11,22,33,44).change(:sec => 7) + assert_equal Time.local(2005,1,2,11,22,33, 8), Time.local(2005,1,2,11,22,33,44).change(:usec => 8) end def test_utc_change |