From 6503da69910beb382b18127c51cd318631245607 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 30 May 2007 06:21:08 +0000 Subject: Time durations use since instead of + for accuracy. Closes #8513. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6901 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/date_time/calculations.rb | 2 +- activesupport/lib/active_support/duration.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index dd30dd07bc..3e62891fcf 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -45,7 +45,7 @@ module ActiveSupport #:nodoc: # Returns a new DateTime representing the time a number of seconds since the instance time # Do not use this method in combination with x.months, use months_since instead! def since(seconds) - self + Rational(seconds, 86400) + self + Rational(seconds.round, 86400) end alias :in :since diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb index 5279c4435a..721bc18795 100644 --- a/activesupport/lib/active_support/duration.rb +++ b/activesupport/lib/active_support/duration.rb @@ -67,7 +67,7 @@ module ActiveSupport parts.inject(time) do |t,(type,number)| if t.acts_like?(:time) if type == :seconds - t + (sign * number) + t.since(sign * number) else t.advance(type => sign * number) end -- cgit v1.2.3