aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-07-31 09:16:21 +0000
committerJamis Buck <jamis@37signals.com>2005-07-31 09:16:21 +0000
commitb4c34f7b2b18720381b3c8cfa79f66a530b3ed0b (patch)
tree51a580e8abe48f6a9f0022d0004e8494245a7fe5 /activesupport
parenteda17194700d4cdc0d863ae8c49a8e3dbbf1615c (diff)
downloadrails-b4c34f7b2b18720381b3c8cfa79f66a530b3ed0b.tar.gz
rails-b4c34f7b2b18720381b3c8cfa79f66a530b3ed0b.tar.bz2
rails-b4c34f7b2b18720381b3c8cfa79f66a530b3ed0b.zip
Fixed that Time#midnight would have a non-zero usec on some platforms #1836
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1959 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb4
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb9
3 files changed, 12 insertions, 3 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 2e2e16ccd9..315ea30568 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that Time#midnight would have a non-zero usec on some platforms #1836
+
* Fixed inflections of "index/indices" #1766 [damn_pepe@gmail.com]
* Added stripping of _id to String#humanize, so "employee_id" becomes "Employee" #1574 [Justin French]
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 8247003ca3..503717f4fe 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -101,7 +101,7 @@ module ActiveSupport #:nodoc:
# Returns a new Time representing the start of the day (0:00)
def beginning_of_day
- self - self.seconds_since_midnight
+ (self - self.seconds_since_midnight).change(:usec => 0)
end
alias :midnight :beginning_of_day
alias :at_midnight :beginning_of_day
@@ -132,4 +132,4 @@ module ActiveSupport #:nodoc:
end
end
end
-end \ No newline at end of file
+end
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 6be1a70f94..dca810d67e 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -130,4 +130,11 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
def test_to_time
assert_equal Time.local(2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30).to_time
end
-end \ No newline at end of file
+
+ # NOTE: this test seems to fail (changeset 1958) only on certain platforms,
+ # like OSX, and FreeBSD 5.4.
+ def test_fp_inaccuracy_ticket_1836
+ midnight = Time.local(2005, 2, 21, 0, 0, 0)
+ assert_equal midnight.midnight, (midnight + 1.hour + 0.000001).midnight
+ end
+end