diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-13 20:13:18 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-10-13 20:13:18 +0000 |
commit | a8077355edef04d2e1844529d6d146bbe41dfa3a (patch) | |
tree | 0d0bc53696ef2915eb2070a91efe5ecbea20896d /activesupport/lib/active_support | |
parent | 9e96286e7aa6d0656d1c8481635dc7e2dca6e067 (diff) | |
download | rails-a8077355edef04d2e1844529d6d146bbe41dfa3a.tar.gz rails-a8077355edef04d2e1844529d6d146bbe41dfa3a.tar.bz2 rails-a8077355edef04d2e1844529d6d146bbe41dfa3a.zip |
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
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date/calculations.rb | 4 |
1 files changed, 2 insertions, 2 deletions
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) |