I18n.localize from "i18n-js" changes the resource time zone

When I have just:


I see this in my browser:


If I run in the Pry console, I see:

[2] pry(#<RSpec::ExampleGroups::Events::GETEvents>)> resource.starts_at
=> Sun, 24 Apr 2022 15:00:00.000000000 UTC +00:00
[3] pry(#<RSpec::ExampleGroups::Events::GETEvents>)> resource.starts_at.strftime('%H:%M:%S')
=> "15:00:00"

I would like to format this to “15:00:00”, so I run the following in the Chrome console:

I18n.localize('date.formats.events_time_format',  "2022-04-24T15:00:00.0007Z")

However instead of 15:00:00 it shows me 16:00:00 – how can I get it to show me 15:00:00 please?

As a workaround I added this to my javascript (jsx) code:

 { I18n.localize('date.formats.events_time_format', resource.starts_at.slice(0, -1)) }

This works but feels messy. Any better solution?

EDIT: This appears to be either a bug or a new behaviour as it worked as expected in Rails6, filed a bug here: I18n.localize changes the resource time zone · Issue #999 · svenfuchs/rails-i18n · GitHub