fix: wrong dates on OOO due to summer time (#20408)

* fix: wrong dates on OOO due to summer time

* update styles

* fix test

* fix edit button
This commit is contained in:
Eunjae Lee authored and GitHub committed 2025-03-28 21:00:56 +05:30
1 parent 48016e0f3e
commit a7b1981cf1
6 files changed
+30 -19

No files matched your search

@@ -56,7 +56,8 @@ describe("outOfOfficeCreateOrUpdate", () => {
startDate: new Date("2024-11-23T23:00:00.000Z"),
endDate: new Date("2024-11-22T23:00:00.000Z"),
},
offset: 60,
startDateOffset: 60,
endDateOffset: 60,
reasonId: 1,
notes: "",
toTeamUserId: null,
@@ -70,16 +71,17 @@ describe("outOfOfficeCreateOrUpdate", () => {
it("should handle timezone offset correctly", async () => {
const input = {
dateRange: {
startDate: new Date("2024-11-23T23:00:00.000Z"),
endDate: new Date("2024-11-23T23:00:00.000Z"),
startDate: new Date("2025-03-28T23:00:00.000Z"),
endDate: new Date("2025-04-01T22:00:00.000Z"),
},
offset: 60, // Paris timezone offset in minutes
startDateOffset: 60, // Paris timezone (CET)
endDateOffset: 120, // Paris timezone (CEST) <- After summer time begins
reasonId: 1,
notes: "",
toTeamUserId: null,
};
const startTimeUtc = "2024-11-24T00:00:00.000Z";
const endTimeUtc = "2024-11-24T23:59:59.999Z";
const startTimeUtc = "2025-03-29T00:00:00.000Z";
const endTimeUtc = "2025-04-02T23:59:59.999Z";
await outOfOfficeCreateOrUpdate({
ctx: { user: mockUser },
@@ -31,8 +31,8 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
throw new TRPCError({ code: "BAD_REQUEST", message: "start_date_and_end_date_required" });
}
const startTimeUtc = dayjs.utc(startDate).add(input.offset, "minute").startOf("day");
const endTimeUtc = dayjs.utc(endDate).add(input.offset, "minute").endOf("day");
const startTimeUtc = dayjs.utc(startDate).add(input.startDateOffset, "minute").startOf("day");
const endTimeUtc = dayjs.utc(endDate).add(input.endDateOffset, "minute").endOf("day");
// If start date is after end date throw error
if (startTimeUtc.isAfter(endTimeUtc)) {
@@ -7,7 +7,8 @@ export const ZOutOfOfficeInputSchema = z.object({
startDate: z.date(),
endDate: z.date(),
}),
offset: z.number(),
startDateOffset: z.number(),
endDateOffset: z.number(),
toTeamUserId: z.number().nullable(),
reasonId: z.number(),
notes: z.string().nullable().optional(),