From 8275d9c13c3b7551e55d1d0862d86faa56505056 Mon Sep 17 00:00:00 2001 From: Iain Beeston Date: Wed, 8 Jun 2022 16:32:11 +0100 Subject: [PATCH] Fix `DEPRECATION WARNING: TimeWithZone#to_s(:short)` Rails has deprecated passing a parameter to `to_s` and now expects `to_formatted_s` to be used instead. This is the full error I see: DEPRECATION WARNING: TimeWithZone#to_s(:short) is deprecated. Please use TimeWithZone#to_fs(:short) instead. (called from to_s at /ice-cube-ruby/ice_cube/lib/ice_cube/occurrence.rb:89) --- lib/ice_cube/occurrence.rb | 2 +- spec/examples/occurrence_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ice_cube/occurrence.rb b/lib/ice_cube/occurrence.rb index 4c51f962..4cd849f5 100644 --- a/lib/ice_cube/occurrence.rb +++ b/lib/ice_cube/occurrence.rb @@ -86,7 +86,7 @@ def to_time # def to_s(format = nil) if format && to_time.public_method(:to_s).arity != 0 - t0, t1 = start_time.to_s(format), end_time.to_s(format) + t0, t1 = start_time.to_formatted_s(format), end_time.to_formatted_s(format) else t0, t1 = start_time.to_s, end_time.to_s end diff --git a/spec/examples/occurrence_spec.rb b/spec/examples/occurrence_spec.rb index 80c18421..45f320ff 100644 --- a/spec/examples/occurrence_spec.rb +++ b/spec/examples/occurrence_spec.rb @@ -28,7 +28,7 @@ time_now = Time.current occurrence = Occurrence.new(time_now) - expect(occurrence.to_s(:short)).to eq time_now.to_s(:short) + expect(occurrence.to_formatted_s(:short)).to eq time_now.to_formatted_s(:short) end end