aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-08-03 00:34:19 +0000
committerRick Olson <technoweenie@gmail.com>2007-08-03 00:34:19 +0000
commit4b6411008675dbbfb7da4dfb6ef73c5528c196d1 (patch)
tree7c9012bb5296ffb04c9576bbc29d61f5b8a4d0da /activesupport/lib/active_support/core_ext/date_time
parentbbbc45156bb2f903513116036619b78065f6d7e8 (diff)
downloadrails-4b6411008675dbbfb7da4dfb6ef73c5528c196d1.tar.gz
rails-4b6411008675dbbfb7da4dfb6ef73c5528c196d1.tar.bz2
rails-4b6411008675dbbfb7da4dfb6ef73c5528c196d1.zip
Fix Time#advance bug when trying to advance a year from leap day. Closes #8655 [gbuesing]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7262 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb4
1 files changed, 1 insertions, 3 deletions
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 8e4197d34b..e16ad55fbd 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -30,9 +30,7 @@ module ActiveSupport #:nodoc:
# Uses Date to provide precise Time calculations for years, months, and days. The +options+ parameter takes a hash with
# any of these keys: :months, :days, :years.
def advance(options)
- d = ::Date.new(year + (options.delete(:years) || 0), month, day)
- d = d >> options.delete(:months) if options[:months]
- d = d + options.delete(:days) if options[:days]
+ d = to_date.advance(options)
change(options.merge(:year => d.year, :month => d.month, :day => d.day))
end