Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix that Dates couldn't be subtracted from Dates after [5940].

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5954 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 312e6edf914a8b561feacac2486d97e7904472e5 1 parent 521ca37
@sstephenson sstephenson authored
View
2  activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Fix that Dates couldn't be subtracted from Dates after [5940]. [Sam Stephenson]
+
* Add Object#acts_like? and Time#acts_like_time? and Date#acts_like_date? to facilitate duck-typing. [Jamis Buck]
* Make 1.months and friends accurate by introducing a Duration class. #6835 [eventualbuddha]
View
6 activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -23,7 +23,11 @@ def plus_with_duration(other) #:nodoc:
end
def minus_with_duration(other) #:nodoc:
- self.plus_with_duration(-other)
+ if ActiveSupport::Duration === other
+ plus_with_duration(-other)
+ else
+ minus_without_duration(other)
+ end
end
# Provides precise Date calculations for years, months, and days. The +options+ parameter takes a hash with
View
6 activesupport/test/core_ext/duration_test.rb
@@ -10,4 +10,8 @@ def test_inspect
assert_equal '7 days', 1.week.inspect
assert_equal '14 days', 1.fortnight.inspect
end
-end
+
+ def test_minus_with_duration_does_not_break_subtraction_of_date_from_date
+ assert_nothing_raised { Date.today - Date.today }
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.