From 8ef3dfff7a48bd0609ba4067c54910880fc6ef88 Mon Sep 17 00:00:00 2001 From: Geoff Buesing Date: Sat, 26 Jan 2008 00:34:44 +0000 Subject: TimeWithZone#- added, so that #- can handle a Time or TimeWithZone argument correctly git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8732 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/time_with_zone.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activesupport/lib') 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 -- cgit v1.2.3