Merge pull request #18063 from claudiob/remove-as-time-with-zone-since
Replace AS::TimeWithZone#since with alias to +
This commit is contained in:
commit
320f75baaf
@ -276,6 +276,7 @@ def +(other)
|
|||||||
result.in_time_zone(time_zone)
|
result.in_time_zone(time_zone)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
alias_method :since, :+
|
||||||
|
|
||||||
# Returns a new TimeWithZone object that represents the difference between
|
# Returns a new TimeWithZone object that represents the difference between
|
||||||
# the current object's time and the +other+ time.
|
# the current object's time and the +other+ time.
|
||||||
@ -304,16 +305,6 @@ def -(other)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def since(other)
|
|
||||||
# If we're adding a Duration of variable length (i.e., years, months, days), move forward from #time,
|
|
||||||
# otherwise move forward from #utc, for accuracy when moving across DST boundaries
|
|
||||||
if duration_of_variable_length?(other)
|
|
||||||
method_missing(:since, other)
|
|
||||||
else
|
|
||||||
utc.since(other).in_time_zone(time_zone)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def ago(other)
|
def ago(other)
|
||||||
since(-other)
|
since(-other)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user