Skip to content

Commit 4ac5ee9

Browse files
committed
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 ```
1 parent 339035c commit 4ac5ee9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

activesupport/lib/active_support/time_with_zone.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ def ago(other)
375375
#
376376
# t = Time.zone.now # => Fri, 14 Apr 2017 11:45:15.116992711 EST -05:00
377377
# t.change(year: 2020) # => Tue, 14 Apr 2020 11:45:15.116992711 EST -05:00
378-
# t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.116992711 EST -05:00
379-
# t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.116992711 EST -05:00
378+
# t.change(hour: 12) # => Fri, 14 Apr 2017 12:00:00.000000000 EST -05:00
379+
# t.change(min: 30) # => Fri, 14 Apr 2017 11:30:00.000000000 EST -05:00
380380
# t.change(offset: "-10:00") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00
381381
# t.change(zone: "Hawaii") # => Fri, 14 Apr 2017 11:45:15.116992711 HST -10:00
382382
def change(options)

0 commit comments

Comments
 (0)