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

This commit is contained in:
Anik Dhabal Babu authored and GitHub committed 2024-09-25 13:44:42 +00:00
1 parent 715cbc1c38
commit 2b24b4472d
1 file changed
+1 -9
@@ -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" });
}