From 389616e68d2b4f1f48014cf9d6d45754936c7bed Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 13 Oct 2007 21:47:45 +0000 Subject: Fix Time#years_ago and #years_since from leap days. Closes #9865. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7867 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/time/calculations.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/time/calculations.rb') diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 94d660afbd..d594cf21f9 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -110,12 +110,12 @@ module ActiveSupport #:nodoc: # Returns a new Time representing the time a number of specified years ago def years_ago(years) - change(:year => self.year - years) + advance(:years => -years) end # Returns a new Time representing the time a number of specified years in the future def years_since(years) - change(:year => self.year + years) + advance(:years => years) end # Short-hand for years_ago(1) -- cgit v1.2.3