Skip to content

Commit 4867559

Browse files
authored
Merge pull request rails#52084 from jhawthorn/time_with_zone_always_time
Remove dead code for DateTime-backed TimeWithZone
2 parents 36b2dbf + 725ebc9 commit 4867559

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

activesupport/lib/active_support/time_with_zone.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def +(other)
300300
if duration_of_variable_length?(other)
301301
method_missing(:+, other)
302302
else
303-
result = utc.acts_like?(:date) ? utc.since(other) : utc + other rescue utc.since(other)
303+
result = utc + other
304304
result.in_time_zone(time_zone)
305305
end
306306
end
@@ -336,7 +336,7 @@ def -(other)
336336
elsif duration_of_variable_length?(other)
337337
method_missing(:-, other)
338338
else
339-
result = utc.acts_like?(:date) ? utc.ago(other) : utc - other rescue utc.ago(other)
339+
result = utc - other
340340
result.in_time_zone(time_zone)
341341
end
342342
end
@@ -537,7 +537,6 @@ def respond_to?(sym, include_priv = false)
537537
# Ensure proxy class responds to all methods that underlying time instance
538538
# responds to.
539539
def respond_to_missing?(sym, include_priv)
540-
return false if sym.to_sym == :acts_like_date?
541540
time.respond_to?(sym, include_priv)
542541
end
543542

activesupport/test/core_ext/time_with_zone_test.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,10 @@ def test_plus_with_integer_when_self_wraps_datetime
394394
assert_equal DateTime.civil(1999, 12, 31, 19, 0, 5), (twz + 5).time
395395
end
396396

397-
def test_plus_when_crossing_time_class_limit
398-
twz = ActiveSupport::TimeWithZone.new(Time.utc(2038, 1, 19), @time_zone)
399-
assert_equal [0, 0, 19, 19, 1, 2038], (twz + 86_400).to_a[0, 6]
397+
def test_no_limit_on_times
398+
twz = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), @time_zone)
399+
assert_equal [0, 0, 19, 31, 12, 11999], (twz + 10_000.years).to_a[0, 6]
400+
assert_equal [0, 0, 19, 31, 12, -8001], (twz - 10_000.years).to_a[0, 6]
400401
end
401402

402403
def test_plus_with_duration

0 commit comments

Comments
 (0)