You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking for TimeWithZone doc, I understood that this should return time in the defined timezone.
Time.zone='Eastern Time (US & Canada)'# => 'Eastern Time (US & Canada)'Time.zone.local(2007,2,10,15,30,45)# => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00Time.zone.parse('2007-02-10 15:30:45')# => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00Time.zone.at(1171139445)# => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00Time.zone.now# => Sun, 18 May 2008 13:07:55.754107581 EST -05:00Time.utc(2007,2,10,20,30,45).in_time_zone# => Sat, 10 Feb 2007 15:30:45.000000000 EST -05:00
Actual behavior
However, what I see is Time.zone.now returning a different timezone from others. As docs.
Shouldn't they all return the same timezone?
I realized that when I'm using a time field and it started to show my time aways 1 hour ahead.
And I saw that is uses Time.local to cast:
I know this is strange and confusing, but the behavior is correct.
The normal timezone for Brazil is -03:00, but in 2007-02-10 Brazil was in the -02:00 timezone because in this date Brazil was using a DST (summer time).
Steps to reproduce
Expected behavior
Looking for TimeWithZone doc, I understood that this should return time in the defined timezone.
Actual behavior
However, what I see is Time.zone.now returning a different timezone from others. As docs.
Shouldn't they all return the same timezone?
I realized that when I'm using a time field and it started to show my time aways 1 hour ahead.
And I saw that is uses Time.local to cast:
rails/activemodel/lib/active_model/type/helpers/time_value.rb
Line 61 in 3258979
It seems that all methods, except
Time.zone.now
are using brazilian summer time instead of use brazilian time.System configuration
Rails version: 7.0.3.1
Ruby version: 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux-musl]
The text was updated successfully, but these errors were encountered: