Skip to content

fix: pass booking date to getUTCOffsetByTimezone to handle DST correctly#28519

Open
neilspaul wants to merge 1 commit intocalcom:mainfrom
neilspaul:fix/dst-offset-in-booking-validation
Open

fix: pass booking date to getUTCOffsetByTimezone to handle DST correctly#28519
neilspaul wants to merge 1 commit intocalcom:mainfrom
neilspaul:fix/dst-offset-in-booking-validation

Conversation

@neilspaul
Copy link

What does this PR do?

Fixes a DST timezone offset bug where getUTCOffsetByTimezone() was called without a date, causing it to use the current moment's UTC offset instead of the booking date's offset.

For DST-observing timezones (e.g. America/Los_Angeles), the UTC offset differs between PST (-480 min) and PDT (-420 min). When the booking date falls in a different DST period than "now", the wrong offset was fed into calculatePeriodLimits and isOutOfBounds, shifting period boundaries and causing bookings to appear at incorrect times for cross-timezone users (e.g. PDT booker → IST host).

What changed?

  • validateBookingTimeIsNotOutOfBounds.ts: Pass reqBodyStartTime (already available as a parameter) to getUTCOffsetByTimezone so the offset matches the booking date, not the current date
  • slots/util.ts: Pass input.startTime to getUTCOffsetByTimezone so slot period limits use the correct DST offset

Both are 2-line changes. The getUTCOffsetByTimezone function already accepts an optional date parameter — it just wasn't being used at these call sites.

How to test

  1. Set host timezone to Asia/Kolkata (IST)
  2. Set booker timezone to America/Los_Angeles
  3. Book a slot in July (PDT) — verify the time shows correctly in IST
  4. Book a slot in January (PST) — verify the time shows correctly in IST
  5. Run unit tests:
    TZ=UTC yarn vitest run packages/lib/dayjs/getUTCOffsetByTimezone.test.ts
    TZ=UTC yarn vitest run packages/features/bookings/lib/handleNewBooking/validateBookingTimeIsNotOutOfBounds.test.ts

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent PR review)
  • I have updated the developer docs (if relevant)
  • I have added tests to cover my changes (if relevant)
  • I have run the relevant tests and they pass

Made with Cursor

getUTCOffsetByTimezone() was called without a date in booking validation
and slot period-limit calculation. This caused it to use the current
moment's UTC offset instead of the booking date's offset for DST-
observing timezones (e.g. America/Los_Angeles). When the booking date
falls in a different DST period than "now", the wrong offset was used,
shifting period boundaries and causing bookings to appear at incorrect
times for cross-timezone users (e.g. PDT booker → IST host).

The fix passes the booking/slot start time as the second argument so the
offset is computed for the correct date.

Made-with: Cursor
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Neil seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@neilspaul neilspaul marked this pull request as ready for review March 20, 2026 13:46
@neilspaul neilspaul requested a review from a team as a code owner March 20, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants