aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/operators.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-28 23:37:03 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-05-28 23:37:03 -0300
commit6e83a133f7d555948c02abd4dc40abb84790210c (patch)
tree0c6dcf8a2ed0bf2d8c947f881a1f3d34d4e5f352 /activesupport/lib/active_support/core_ext/date/operators.rb
parent9ff901bd3e046b0373b28459269146707b5bf8c9 (diff)
parentbbe7b7f504ea5010712ee37d84f8c86682dd14f8 (diff)
downloadrails-6e83a133f7d555948c02abd4dc40abb84790210c.tar.gz
rails-6e83a133f7d555948c02abd4dc40abb84790210c.tar.bz2
rails-6e83a133f7d555948c02abd4dc40abb84790210c.zip
Merge pull request #19878 from pabloh/replace_alias_chains_with_prepend
Replace use of alias chains with prepend at core_ext/date and core_ext/time
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date/operators.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/operators.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/operators.rb b/activesupport/lib/active_support/core_ext/date/operators.rb
new file mode 100644
index 0000000000..decf099624
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/date/operators.rb
@@ -0,0 +1,16 @@
+require 'active_support/core_ext/date_and_time/with_duration'
+
+module ActiveSupport
+ module DateOperators # :nodoc:
+ include DateAndTime::WithDuration
+
+ # Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there.
+ def <=>(other)
+ if other.is_a?(Time)
+ self.to_datetime <=> other
+ else
+ super
+ end
+ end
+ end
+end