Fix deprecation warning for to_time

Warning was:

> DEPRECATION WARNING: `to_time` will always preserve the full timezone
> rather than offset of the receiver in Rails 8.1. To opt in to the new
> behavior, set `config.active_support.to_time_preserves_timezone =
> :zone`.

Actually we were already using `:zone`, but it was set in a file
required late in the loading process. Moving it to
`config/application.rb` fixes the deprecation warning.
This commit is contained in:
Christophe Bliard
2025-10-21 12:07:53 +02:00
parent a1ca3b22f7
commit 996abfa4da
2 changed files with 7 additions and 8 deletions
+7
View File
@@ -167,6 +167,13 @@ module OpenProject
# Include tstzrange columns in the list of time zone aware types
ActiveRecord::Base.time_zone_aware_types += [:tstzrange]
# Specifies whether `to_time` methods preserve the UTC offset of their receivers
# or preserves the timezone. Rails 8.0+ default is `:zone`.
# If set to `:zone`, `to_time` methods will use the timezone of their receivers.
# If set to `:offset`, `to_time` methods will use the UTC offset.
# If `false`, `to_time` methods will convert to the local system UTC offset instead.
config.active_support.to_time_preserves_timezone = :zone
# Activate being able to specify the format in which full_message works.
# Doing this, it is e.g. possible to avoid having the format of '%{attribute} %{message}' which
# will always prepend the attribute name to the error message.
@@ -39,14 +39,6 @@
# Read the Guide for Upgrading Ruby on Rails for more info on each option.
# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
###
# Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone.
# If set to `:zone`, `to_time` methods will use the timezone of their receivers.
# If set to `:offset`, `to_time` methods will use the UTC offset.
# If `false`, `to_time` methods will convert to the local system UTC offset instead.
#++
Rails.application.config.active_support.to_time_preserves_timezone = :zone
###
# When both `If-Modified-Since` and `If-None-Match` are provided by the client
# only consider `If-None-Match` as specified by RFC 7232 Section 6.