5
11
Fork
You've already forked tomato
1

Fix shift occurrence filter to use timezone #157

Merged
edwardloveall merged 1 commit from el-fix-shift-filter-time-zone into main 2026年05月20日 15:39:30 +02:00

When filtering for shift occurrences by date range, it was possible to display
shifts from outside that date range. That's because we were converting the
passed in date to a datetime, and rails was using UTC for that time. So
something at 6pm US Mountain Time would actually be 1am the "next day" in UTC.

To fix this, I stopped trying to treat the passed in dates at times and just
treated them like dates. When we need times, like when filtering shift
occurrences, we convert to a time in the current Time.zone.

When filtering for shift occurrences by date range, it was possible to display shifts from outside that date range. That's because we were converting the passed in date to a datetime, and rails was using UTC for that time. So something at 6pm US Mountain Time would actually be 1am the "next day" in UTC. To fix this, I stopped trying to treat the passed in dates at times and just treated them like dates. When we need times, like when filtering shift occurrences, we convert to a time _in the current Time.zone_.
edwardloveall force-pushed el-fix-shift-filter-time-zone from 8998ce698e
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to d56f925f30
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年05月19日 15:27:18 +02:00
Compare
edwardloveall force-pushed el-fix-shift-filter-time-zone from d56f925f30
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to b08c6c2416
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年05月19日 16:32:15 +02:00
Compare
@ -41,2 +52,4 @@
end
def starts_at
starts_on.in_time_zone(Time.zone).beginning_of_day
First-time contributor
Copy link

I'm fine with the explicitness here but just wanted to mention that Time.zone is the default for the param on in_time_zone. Docs

I'm fine with the explicitness here but just wanted to mention that `Time.zone` is the default for the param on `in_time_zone`. [Docs](https://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html#method-i-in_time_zone)
Author
Owner
Copy link

Oh, yeah that make sense. Good catch. I think I like the explicitness, too. in_time_zone really feels like it wants an argument.

Oh, yeah that make sense. Good catch. I think I like the explicitness, too. `in_time_zone` really feels like it wants an argument.
edwardloveall force-pushed el-fix-shift-filter-time-zone from b08c6c2416
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 16b5e64e81
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年05月20日 15:30:27 +02:00
Compare
Author
Owner
Copy link

Flaky test is flaky, but not actually failing.

Flaky test is flaky, but not actually failing.
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
2 participants
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!157
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-fix-shift-filter-time-zone"

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?