Advanced date override handling and timezone compatibility improvements#5
Advanced date override handling and timezone compatibility improvements#5akshayutture-augment wants to merge 1 commit into
Conversation
* 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>
There was a problem hiding this comment.
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
cursor-cal_dot_com/packages/trpc/server/routers/viewer/slots.ts
Lines 530 to 531 in 3ef3284
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
cursor-cal_dot_com/packages/trpc/server/routers/viewer/slots.ts
Lines 551 to 552 in 3ef3284
| workingHours.find((workingHour) => { | ||
| if (workingHour.days.includes(slotStartTime.day())) { | ||
| const start = slotStartTime.hour() * 60 + slotStartTime.minute(); | ||
| const end = slotStartTime.hour() * 60 + slotStartTime.minute(); |
There was a problem hiding this comment.
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.
| slotStartTime.format("YYYY MM DD") | ||
| ) { | ||
| dateOverrideExist = true; | ||
| if (dayjs(date.start).add(utcOffset, "minutes") === dayjs(date.end).add(utcOffset, "minutes")) { |
There was a problem hiding this comment.
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.
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.
dateOverrideshandling inlib/slotsto compute override windows using organizer vs invitee UTC offsets; replace matching working hours with overrides.checkIfIsAvailableto respect date overrides and working hours with organizer timezone context; short-circuit availability accordingly.organizerTimeZonethrough schedule generation; derive fromeventType/schedule/user and use for fixed/loose host checks and selected slot filtering.timeZonein flatteneddateOverridesand importWorkingHourstype.TimeRangewith optionaltimeZone.Written by Cursor Bugbot for commit 3ef3284. Configure here.