I've noticed a time zone bug in the following code...

https://github.com/rails/rails/blob/f33d52c95217212cbacc8d5e44b5a8e3cdc6f5b3/activemodel/lib/active_model/type/helpers/time_value.rb#L59

That's creating a new time with either :utc or :local.  The issue is when
using :local, that creates a new time based on the systems local time zone,
and ignores the time set in the app via config.time_zone = 'Central Time
(US & Canada)'

So if the app is set for CST (via config.time_zone), but the local system
time zone in EST, the time will be created for EST even if the app is set
for CST.

So in code such as

class FormObject
  include ActiveModel::Model
  include ActiveModel::Attributes
  include ActiveRecord::AttributeAssignment
  attribute :received_at, :datetimeend

obj = FormObject.new received_at: '2020-01-02 00:50'
obj.received_at # 2020-01-02 00:50:00 -0500 => should be 2020-01-02
00:50:00 -0600

The resulting time is wrong because the time zone set in the app is being
ignored.

Any reason this would be occurring the way it is or is it a bug?

Regards,
Andrew

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-core/CAEUKiYFTjFQSXGz3XbSc%2B31HfTw%2BBWJt%3DpHGNHvmqJ7RDmg6Ew%40mail.gmail.com.

Reply via email to