File tree 1 file changed +23
-0
lines changed
activesupport/lib/active_support/core_ext/date_time
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,29 @@ def end_of_day
81
81
change ( :hour => 23 , :min => 59 , :sec => 59 )
82
82
end
83
83
84
+ # 1.9.3 defines + and - on DateTime, < 1.9.3 do not.
85
+ if DateTime . public_instance_methods ( false ) . include? ( :+ )
86
+ def plus_with_duration ( other ) #:nodoc:
87
+ if ActiveSupport ::Duration === other
88
+ other . since ( self )
89
+ else
90
+ plus_without_duration ( other )
91
+ end
92
+ end
93
+ alias_method :plus_without_duration , :+
94
+ alias_method :+ , :plus_with_duration
95
+
96
+ def minus_with_duration ( other ) #:nodoc:
97
+ if ActiveSupport ::Duration === other
98
+ plus_with_duration ( -other )
99
+ else
100
+ minus_without_duration ( other )
101
+ end
102
+ end
103
+ alias_method :minus_without_duration , :-
104
+ alias_method :- , :minus_with_duration
105
+ end
106
+
84
107
# Adjusts DateTime to UTC by adding its offset value; offset is set to 0
85
108
#
86
109
# Example:
You can’t perform that action at this time.
0 commit comments