Skip to content

Scheduling infrastructure for absolutely everyone.

fix: OOO issue with setting the start and end dates to the same (#16810)

Anik Dhabal Babu2b24b4472d6e
diff --git a/packages/trpc/server/routers/loggedInViewer/outOfOffice.handler.ts b/packages/trpc/server/routers/loggedInViewer/outOfOffice.handler.ts
index 53a1110abe5..43f427ad0c9 100644
--- a/packages/trpc/server/routers/loggedInViewer/outOfOffice.handler.ts
+++ b/packages/trpc/server/routers/loggedInViewer/outOfOffice.handler.ts
@@ -32,7 +32,6 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
const inputStartTime = dayjs(startDate).startOf("day");
const inputEndTime = dayjs(endDate).endOf("day");
- const offset = dayjs(inputStartTime).utcOffset();
// If start date is after end date throw error
if (inputStartTime.isAfter(inputEndTime)) {
@@ -40,14 +39,7 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
}
// If start date is before to today throw error
- // Since this validation is done using server tz, we need to account for the offset
- if (
- inputStartTime.isBefore(
- dayjs()
- .startOf("day")
- .subtract(Math.abs(offset) * 60, "minute")
- )
- ) {
+ if (inputStartTime.isBefore(dayjs().startOf("day").subtract(1, "day"))) {
throw new TRPCError({ code: "BAD_REQUEST", message: "start_date_must_be_in_the_future" });
}