From 05d9f70b456817c4f0d1f87453474f5e85fb44f0 Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Fri, 5 Jun 2026 15:28:26 -0400 Subject: [PATCH] fix(02): window occurrences in UTC, not server-local timezone ICAL.Time.fromJSDate(window, false) interpreted the UTC-midnight window bounds in the server's local TZ (America/New_York in dev), shifting the window by the server offset and dropping evening occurrences near a day window's end (e.g. June 11 17:45-04:00 = 21:45Z was excluded from the June-11 day view). Use UTC so the window is deterministic and correct. --- apps/api/src/broker/expand.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/api/src/broker/expand.ts b/apps/api/src/broker/expand.ts index 2c003f8..e052b23 100644 --- a/apps/api/src/broker/expand.ts +++ b/apps/api/src/broker/expand.ts @@ -209,8 +209,13 @@ export function expandOccurrences( const allDay: boolean = dtstart.isDate const uid: string = event.uid ?? '' - const rangeStart = ICAL.Time.fromJSDate(windowStart, false) - const rangeEnd = ICAL.Time.fromJSDate(windowEnd, false) + // useUTC=true: windowStart/windowEnd are absolute instants (midnight-UTC of the + // requested dates). Interpreting them in UTC keeps the occurrence-window comparison + // absolute. With useUTC=false ical.js used the SERVER's local timezone, shifting the + // window by the server's offset and dropping evening occurrences near the window end + // (e.g. a 17:45-04:00 event = 21:45Z fell past a day window whose end was shifted to 20:00). + const rangeStart = ICAL.Time.fromJSDate(windowStart, true) + const rangeEnd = ICAL.Time.fromJSDate(windowEnd, true) const occurrences: CalendarOccurrence[] = []