From a8077355edef04d2e1844529d6d146bbe41dfa3a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 13 Oct 2007 20:13:18 +0000 Subject: Fix Date#years_ago and #years_since from leap days. Closes #9864. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7863 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/date/calculations.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb index c1f4eb21be..9da7303f27 100644 --- a/activesupport/lib/active_support/core_ext/date/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date/calculations.rb @@ -103,12 +103,12 @@ module ActiveSupport #:nodoc: # Returns a new Date/DateTime 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 Date/DateTime 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