5
11
Fork
You've already forked tomato
1

Respect DST in user time zones #8

Merged
edwardloveall merged 1 commit from el-fix-volunteer-utc-offset into main 2025年08月06日 20:54:42 +02:00

The frontend requests /api/users/me.json to get the user's timezone offset. We were calculating that offset using rails' ActiveSupport::TimeZone#formatted_offset method. However, this is just an abstract zone like "America/New_York" where the offset changes with the switch to daylight savings time. A single offset doesn't make sense!

Instead, we want to ask what is the offset right now by calling #now on the time zone then calling formatted_offset on that. This knows how to adjust the offset based on the presence or absence of daylight savings time.

The frontend requests `/api/users/me.json` to get the user's timezone offset. We were calculating that offset using rails' [`ActiveSupport::TimeZone#formatted_offset`][zone_offset] method. However, this is just an abstract zone like "America/New_York" where the offset changes with the switch to daylight savings time. A single offset doesn't make sense! Instead, we want to ask what is the offset _right now_ by calling `#now` on the time zone then calling [`formatted_offset`][time_offset] on that. This knows how to adjust the offset based on the presence or absence of daylight savings time. [zone_offset]: https://api.rubyonrails.org/v7.1/classes/ActiveSupport/TimeZone.html#method-i-formatted_offset [time_offset]: https://api.rubyonrails.org/v7.1/classes/ActiveSupport/TimeWithZone.html#method-i-formatted_offset
Respect DST in user time zones
All checks were successful
Setup Successful
Jest Successful
RSpec Successful
Static Analysis Successful
0bb8c8ad87
The frontend requests `/api/users/me.json` to get the user's timezone
offset. We were calculating that offset using rails'
[`ActiveSupport::TimeZone#formatted_offset`][zone_offset] method.
However, this is just an abstract zone like "America/New_York" where
the offset changes with the switch to daylight savings time. A single
offset doesn't make sense!
Instead, we want to ask what is the offset _right now_ by calling
`#now` on the time zone then calling [`formatted_offset`][time_offset]
on that. This knows how to adjust the offset based on the presence or
absence of daylight savings time.
[zone_offset]: https://api.rubyonrails.org/v7.1/classes/ActiveSupport/TimeZone.html#method-i-formatted_offset
[time_offset]: https://api.rubyonrails.org/v7.1/classes/ActiveSupport/TimeWithZone.html#method-i-formatted_offset 
Author
Owner
Copy link

@thetizzo we wanted to get this fix out the door so I'm going to merge (the failing test is flaky and I saw it pass locally). Please do feel free to offer suggestions if you have any! I'm happy to make more changes.

@thetizzo we wanted to get this fix out the door so I'm going to merge (the failing test is flaky and I saw it pass locally). Please do feel free to offer suggestions if you have any! I'm happy to make more changes.
edwardloveall deleted branch el-fix-volunteer-utc-offset 2025年08月06日 20:54:43 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rootable/tomato!8
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-fix-volunteer-utc-offset"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?