diff options
author | Roque Pinel <repinel@gmail.com> | 2015-05-29 10:57:15 -0500 |
---|---|---|
committer | Roque Pinel <repinel@gmail.com> | 2015-05-29 10:57:15 -0500 |
commit | af1a61745a8fdab129b83536c324f667a50fafbf (patch) | |
tree | 63085a0d03ea6d6f57b8b62bb5fabaf502ef8833 /activesupport/lib/active_support/core_ext/time/operators.rb | |
parent | 343dad9617e7448bf8effc7c70ae13bede38fd32 (diff) | |
download | rails-af1a61745a8fdab129b83536c324f667a50fafbf.tar.gz rails-af1a61745a8fdab129b83536c324f667a50fafbf.tar.bz2 rails-af1a61745a8fdab129b83536c324f667a50fafbf.zip |
Revert "Replace use of alias chains with prepend at core_ext/date and core_ext/time"
Diffstat (limited to 'activesupport/lib/active_support/core_ext/time/operators.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/operators.rb | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/operators.rb b/activesupport/lib/active_support/core_ext/time/operators.rb deleted file mode 100644 index 161304dcb3..0000000000 --- a/activesupport/lib/active_support/core_ext/time/operators.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'active_support/core_ext/date_and_time/with_duration' - -module ActiveSupport - module TimeOperators # :nodoc: - include DateAndTime::WithDuration - - # Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances - # can be chronologically compared with a Time - def <=>(other) - # we're avoiding Time#to_datetime and Time#to_time because they're expensive - if other.class == Time - super - elsif other.is_a?(Time) - super(other.to_time) - else - to_datetime <=> other - end - end - - # Layers additional behavior on Time#eql? so that ActiveSupport::TimeWithZone instances - # can be eql? to an equivalent Time - def eql?(other) - # if other is an ActiveSupport::TimeWithZone, coerce a Time instance from it so we can do eql? comparison - other = other.comparable_time if other.respond_to?(:comparable_time) - super - end - - # Time#- can also be used to determine the number of seconds between two Time instances. - # We're layering on additional behavior so that ActiveSupport::TimeWithZone instances - # are coerced into values that Time#- will recognize - def -(other) - other = other.comparable_time if other.respond_to?(:comparable_time) - other.is_a?(DateTime) ? to_f - other.to_f : super - end - end -end |