aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index e65c77a8b6..c5810c2c19 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -106,6 +106,12 @@ module ActiveSupport
def <=>(other)
utc <=> other
end
+
+ # Need to override #- to intercept situation where a Time or Time With Zone object is passed in
+ # Otherwise, just pass on to method missing
+ def -(other)
+ other.acts_like?(:time) ? utc - other : method_missing(:-, other)
+ end
# A TimeProxy acts like a Time, so just return self
def to_time