From 2b24b4472d6e8c109c9c7e983dc6dee0e8e79783 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:14:42 +0530 Subject: [PATCH] fix: OOO issue with setting the start and end dates to the same (#16810) --- .../routers/loggedInViewer/outOfOffice.handler.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/trpc/server/routers/loggedInViewer/outOfOffice.handler.ts b/packages/trpc/server/routers/loggedInViewer/outOfOffice.handler.ts index 53a1110abe..43f427ad0c 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" }); }