Permalink
Browse files

Fixed that Time#change should also reset usec when also resetting min…

…utes #2459 [ikeda@dream.big.or.jp]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2568 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 43b6a74 commit f0448f5631288e3b73f9c95ebc1870dd54967a87 @dhh dhh committed Oct 13, 2005
@@ -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>]
@@ -41,7 +41,7 @@ def change(options)
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
@@ -100,6 +100,11 @@ def test_change
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

0 comments on commit f0448f5

Please sign in to comment.