From 4ac5ee9350fc092b7ec660dbcc42805204606cbe Mon Sep 17 00:00:00 2001 From: Judeeeee <43412616+Judeeeee@users.noreply.github.com> Date: Sat, 20 Apr 2024 15:55:20 +0900 Subject: [PATCH] docs: Fix ActiveSupport::TimeWithZone#change example [skip ci] This Pull Request has been created because the documentation for `ActiveSupport::TimeWithZone#change` wasn't correct. The behavior of `:hour` and `:min` is different from the example in the documentation. I checked with Rails 7.1.3.2 and all digits after nano seconds are 0. ```ruby t = Time.zone.now #=> Sat, 20 Apr 2024 14:55:55.688536000 JST +09:00 t.change(hour: 12) #=> Sat, 20 Apr 2024 12:00:00.000000000 JST +09:00 t.change(min: 30) #=> Sat, 20 Apr 2024 14:30:00.000000000 JST +09:00 ``` --- activesupport/lib/active_support/time_with_zone.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 9a5f70d186..f9b020ef4f 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -375,8 +375,8 @@ def ago(other) # # t = Time.zone.now # => Fri, 14 Apr 2017 11:45:15.116992711 EST -05:00 # t.change(year: 2020) # => Tue, 14 Apr 2020 11:45:15.116992711 EST -05:00 - # t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.116992711 EST -05:00 - # t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.116992711 EST -05:00 + # t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.000000000 EST -05:00 + # t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.000000000 EST -05:00 # t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00 # t.change(zone: "Hawaii") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00 def change(options)