fix: apply recurring DST correction in the event timezone#29777
fix: apply recurring DST correction in the event timezone#29777winklemad wants to merge 2 commits into
Conversation
parseRecurringDates computed its per-occurrence DST correction from the runtime's local timezone (dayjs(startDate).utcOffset() and dayjs(t).utcOffset()) instead of the event timeZone. When a booker's browser timezone differs from the meeting timezone, every recurring occurrence after the event zone's DST transition drifted by an hour (e.g. a 10:00 America/New_York weekly slot became 11:00), and those instants are used as the actual booking start/end. Read both offsets in the event timeZone so the wall-clock time stays constant across the DST change.
|
Welcome to Cal.diy, @winklemad! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/lib/parse-dates.ts`:
- Around line 111-112: Remove the redundant “applying the DST offset” comment
immediately before the return statement in the date-parsing logic, leaving the
existing calculation unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 03dbc478-8fed-4731-b851-0fe4243d74dd
📒 Files selected for processing (2)
packages/lib/parse-dates.timezone.test.tspackages/lib/parse-dates.ts
What does this PR do?
parseRecurringDates(packages/lib/parse-dates.ts) computes its per-occurrence DST correction from the runtime's local timezone rather than the eventtimeZone:The booker lets a user pick a meeting timezone independent of their browser timezone, so
browser TZ ≠ meeting TZis normal input. When they differ, every recurring occurrence after the event zone's DST transition drifts by an hour, and these instants are used as the actual booking start/end —parseRecurringDates's returnedDate[]feedsmapRecurringBookingToMutationInput(packages/features/bookings/lib/client/booking-event-form/booking-to-mutation-input-mapper.tsx:107) and the occurrence list inOccurences.tsx. So this is wrong booking times, not just a display glitch.Reproduced with a weekly 10:00
America/New_Yorkbooking crossing US spring-forward (2025-03-09), booker runtimeAsia/Dubai(each instant shown as its New-York wall clock):10:00, 11:00, 11:00, 11:00❌ (post-DST occurrences drift +1h)10:00, 10:00, 10:00, 10:00✅When the runtime timezone equals the event timezone the current code is already correct — confirming the intent is to hold the event-timezone wall-clock, so the cross-timezone drift is a genuine bug.
Fix: read both offsets in the event
timeZone(.tz(timeZone).utcOffset()), matching the function's own comment ("UTC still need to have DST applied").Visual Demo (For contributors especially)
Non-visual (timezone/scheduling logic). The reproduction is the code + before/after above.
Mandatory Tasks (DO NOT REMOVE)
packages/lib/parse-dates.timezone.test.ts).How should this be tested?
packages/lib/parse-dates.timezone.test.ts(runs in theVITEST_MODE=timezonesuite; setsprocess.env.TZ = "Asia/Dubai") asserts a weekly 10:00America/New_Yorkrecurrence crossing the 2025-03-09 DST boundary keeps all four occurrences at 10:00. It fails on the current code (occurrences 2–4 become 11:00) and passes with the fix.parseRecurringDatesis a pure function.["2025-03-05 10:00","2025-03-12 10:00","2025-03-19 10:00","2025-03-26 10:00"](New-York wall clock), regardless of the runtime timezone.