5
11
Fork
You've already forked tomato
1

Fix: new date filter shifting days #132

Merged
edwardloveall merged 1 commit from el-fix-time-range-filter into main 2026年03月31日 17:25:02 +02:00

The new date filter for the shift occurrence page would change the dates you're
looking at if you added a filter. By default it shows almost 7 days; From the
current day at midnight, to just before 8 days from now. That lets us have a 7
day window without displaying events at midnight on the 8th day.

However, this gets weird for two reasons. The new date filter only gives you a
date selector like 03/02/2026. When this is converted to a day, it creates it at
midnight, which effectively cuts off a day.

  • Start 2026年03月01日 00:00 - End 2026年03月07日 23:59
  • Start 2026年03月01日 00:00 - End 2026年03月07日 00:00 🚫

Setting up any filter passes that date through to the filter, which changes the
range.

Also, when you skip through to the next time period, if you base it off a time
slightly before 7 days, it will slowly shift by that difference. That's
because it's using the current ends at at the new starts at (when going
forward). So first it will start at midnight, then it will start 1 microsecond
before, and then 2 microseconds before, etc.

To fix these, I changed the ShiftOccurrenceFilter class to always set the
starts_at to the beginning of whatever day and then end_at to the end of the
day, no matter what's passed in. But when calculating the next time period, it
rounds to the nearest integer in seconds, which keeps the time shift stable.

The new date filter for the shift occurrence page would change the dates you're looking at if you added a filter. By default it shows _almost_ 7 days; From the current day at midnight, to just before 8 days from now. That lets us have a 7 day window without displaying events at midnight on the 8th day. However, this gets weird for two reasons. The new date filter only gives you a date selector like 03/02/2026. When this is converted to a day, it creates it at midnight, which effectively cuts off a day. - Start 2026年03月01日 00:00 - End 2026年03月07日 23:59 ✅ - Start 2026年03月01日 00:00 - End 2026年03月07日 00:00 🚫 Setting up any filter passes that date through to the filter, which changes the range. Also, when you skip through to the next time period, if you base it off a time _slightly_ before 7 days, it will slowly shift by that difference. That's because it's using the current ends at at the new starts at (when going forward). So first it will start at midnight, then it will start 1 microsecond before, and then 2 microseconds before, etc. To fix these, I changed the ShiftOccurrenceFilter class to always set the `starts_at` to the beginning of whatever day and then `end_at` to the end of the day, no matter what's passed in. But when calculating the next time period, it rounds to the nearest integer in seconds, which keeps the time shift stable.
jsilasbailey left a comment
Copy link

You can always get date math right... on the second try!

You can always get date math right... on the second try!
@ -217,2 +215,3 @@
)
prev_filter = filter.next_range
prev_filter = filter.next_range
First-time contributor
Copy link

nit: I think this is next_filter?

nit: I think this is `next_filter`?
edwardloveall force-pushed el-fix-time-range-filter from ad90ebfad3
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to 8cb6d994c1
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年03月31日 17:20:29 +02:00
Compare
edwardloveall deleted branch el-fix-time-range-filter 2026年03月31日 17:25:04 +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
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!132
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-fix-time-range-filter"

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?