Skip to content

Advanced date override handling and timezone compatibility improvements#5

Open
akshayutture-augment wants to merge 1 commit into
date-algorithm-basefrom
date-algorithm-enhanced
Open

Advanced date override handling and timezone compatibility improvements#5
akshayutture-augment wants to merge 1 commit into
date-algorithm-basefrom
date-algorithm-enhanced

Conversation

@akshayutture-augment

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Copy link
Copy Markdown

Test 7


Replicated from ai-code-review-evaluation/cal.com-cursor#7


Note

Make date overrides timezone-aware and apply them in slot/availability calculations, passing organizer timezone through and adding tests and types to support it.

  • Scheduling/Backend:
    • Adjust dateOverrides handling in lib/slots to compute override windows using organizer vs invitee UTC offsets; replace matching working hours with overrides.
    • Enhance checkIfIsAvailable to respect date overrides and working hours with organizer timezone context; short-circuit availability accordingly.
    • Pass organizerTimeZone through schedule generation; derive from eventType/schedule/user and use for fixed/loose host checks and selected slot filtering.
    • Include timeZone in flattened dateOverrides and import WorkingHours type.
  • Tests:
    • Add test ensuring date overrides yield identical UTC slots across different invitee timezones.
  • Types:
    • Extend TimeRange with optional timeZone.

Written by Cursor Bugbot for commit 3ef3284. Configure here.

* fix date override for fixed round robin + time zone in date override

* check if slot is within working hours of fixed hosts

* add test for date override in different time zone

* fix date overrides for not fixed hosts (round robin)

* code clean up

* fix added test

* use the correct timezone of user for date overrides

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bug: Typeof Comparison Error: Always True

The condition typeof availabilityCheckProps.currentSeats !== undefined always evaluates to true because typeof returns a string, not the value undefined. This causes the code block to always execute regardless of whether currentSeats is actually defined, potentially causing runtime errors when trying to map over an undefined value. Should use typeof availabilityCheckProps.currentSeats !== "undefined" or availabilityCheckProps.currentSeats !== undefined.

packages/trpc/server/routers/viewer/slots.ts#L530-L531

const addedToCurrentSeats: string[] = [];
if (typeof availabilityCheckProps.currentSeats !== undefined) {

Fix in Cursor Fix in Web


Bug: Type Check Logic Error Blocks Initialization

The condition typeof availabilityCheckProps.currentSeats === undefined always evaluates to false because typeof returns a string, never the value undefined. This prevents the initialization of currentSeats as an empty array when it should be initialized, causing the subsequent code to fail when trying to push to an undefined array. Should use typeof availabilityCheckProps.currentSeats === "undefined" or availabilityCheckProps.currentSeats === undefined.

packages/trpc/server/routers/viewer/slots.ts#L551-L552

if (occupiedSeats?.length && typeof availabilityCheckProps.currentSeats === undefined)

Fix in Cursor Fix in Web


workingHours.find((workingHour) => {
if (workingHour.days.includes(slotStartTime.day())) {
const start = slotStartTime.hour() * 60 + slotStartTime.minute();
const end = slotStartTime.hour() * 60 + slotStartTime.minute();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Incorrect End Time Disrupts Slot Availability

The end variable is calculated using slotStartTime instead of slotEndTime, making both start and end identical. This breaks the working hours validation logic, causing slots to be incorrectly marked as available or unavailable since the end time check compares the start time against workingHour.endTime.

Fix in Cursor Fix in Web

slotStartTime.format("YYYY MM DD")
) {
dateOverrideExist = true;
if (dayjs(date.start).add(utcOffset, "minutes") === dayjs(date.end).add(utcOffset, "minutes")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Dayjs Comparison Breaks Date Override Handling

Comparing two dayjs objects with === always returns false because it compares object references rather than date values. This causes the date override logic to never detect when start and end times are equal, breaking the handling of zero-duration date overrides. Use .isSame() method instead for proper date comparison.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants