diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 16:36:04 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-05-19 16:36:04 +0000 |
commit | e84deb71d2e8a2855aba01bf88a710c8ae5ab1dc (patch) | |
tree | 35887214f58d22b0281c4fed537fec2b049b9ce9 /activesupport/lib | |
parent | aa20834222e829406bf45b133e6413bedf702229 (diff) | |
download | rails-e84deb71d2e8a2855aba01bf88a710c8ae5ab1dc.tar.gz rails-e84deb71d2e8a2855aba01bf88a710c8ae5ab1dc.tar.bz2 rails-e84deb71d2e8a2855aba01bf88a710c8ae5ab1dc.zip |
Fixed that Time.local(2005,12).months_since(1) would raise "ArgumentError: argument out of range" #1311 [jhahn@niveon.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1308 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index acc84017ab..f238ca168a 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -48,7 +48,8 @@ module ActiveSupport #:nodoc: def months_since(months) if months + self.month > 12 - change(:year => self.year + 1, :month => 1).months_since(months - (self.month == 1 ? 12 : (self.month + 1))) + old_time = self + change(:year => self.year + 1, :month => 1).months_since(months + old_time.month - 12 - 1) else change(:year => self.year, :month => self.month + months) end |