fix: wrong slot starting times for half hour times zones (#10161)
* fix timezone zone issue for first slot * fix failed test in getSchedule * Update apps/web/test/lib/getSchedule.test.ts --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: alannnc <alannnc@gmail.com>pull/10211/head
parent
dad4fd17fb
commit
2db4998eaa
|
@ -451,6 +451,7 @@ describe("getSchedule", () => {
|
||||||
endTime: `${plus2DateString}T18:29:59.999Z`,
|
endTime: `${plus2DateString}T18:29:59.999Z`,
|
||||||
timeZone: Timezones["+5:30"],
|
timeZone: Timezones["+5:30"],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(scheduleForEventWith30Length).toHaveTimeSlots(
|
expect(scheduleForEventWith30Length).toHaveTimeSlots(
|
||||||
[
|
[
|
||||||
`04:00:00.000Z`,
|
`04:00:00.000Z`,
|
||||||
|
@ -484,8 +485,9 @@ describe("getSchedule", () => {
|
||||||
timeZone: Timezones["+5:30"],
|
timeZone: Timezones["+5:30"],
|
||||||
});
|
});
|
||||||
// `slotInterval` takes precedence over `length`
|
// `slotInterval` takes precedence over `length`
|
||||||
|
// 4:30 is utc so it is 10:00 in IST
|
||||||
expect(scheduleForEventWith30minsLengthAndSlotInterval2hrs).toHaveTimeSlots(
|
expect(scheduleForEventWith30minsLengthAndSlotInterval2hrs).toHaveTimeSlots(
|
||||||
[`04:00:00.000Z`, `06:00:00.000Z`, `08:00:00.000Z`, `10:00:00.000Z`, `12:00:00.000Z`],
|
[`04:30:00.000Z`, `06:30:00.000Z`, `08:30:00.000Z`, `10:30:00.000Z`, `12:30:00.000Z`],
|
||||||
{
|
{
|
||||||
dateString: plus2DateString,
|
dateString: plus2DateString,
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,4 +280,23 @@ describe("Tests the slot logic", () => {
|
||||||
|
|
||||||
expect(slots[0].time.format()).toBe("2023-07-13T22:45:00+02:00");
|
expect(slots[0].time.format()).toBe("2023-07-13T22:45:00+02:00");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("tests slots for half hour timezones", async () => {
|
||||||
|
const slots = getSlots({
|
||||||
|
inviteeDate: dayjs.tz("2023-07-13T00:00:00.000+05:30", "Asia/Kolkata"),
|
||||||
|
frequency: 60,
|
||||||
|
minimumBookingNotice: 0,
|
||||||
|
eventLength: 60,
|
||||||
|
organizerTimeZone: "Asia/Kolkata",
|
||||||
|
dateRanges: [
|
||||||
|
{
|
||||||
|
start: dayjs.tz("2023-07-13T07:30:00.000", "Asia/Kolkata"),
|
||||||
|
end: dayjs.tz("2023-07-13T09:30:00.000", "Asia/Kolkata"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(slots).toHaveLength(1);
|
||||||
|
expect(slots[0].time.format()).toBe("2023-07-13T08:00:00+05:30");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -161,6 +161,7 @@ function buildSlotsWithDateRanges({
|
||||||
eventLength = minimumOfOne(eventLength);
|
eventLength = minimumOfOne(eventLength);
|
||||||
offsetStart = offsetStart ? minimumOfOne(offsetStart) : 0;
|
offsetStart = offsetStart ? minimumOfOne(offsetStart) : 0;
|
||||||
const slots: { time: Dayjs; userIds?: number[] }[] = [];
|
const slots: { time: Dayjs; userIds?: number[] }[] = [];
|
||||||
|
|
||||||
dateRanges.forEach((range) => {
|
dateRanges.forEach((range) => {
|
||||||
const startTimeWithMinNotice = dayjs.utc().add(minimumBookingNotice, "minute");
|
const startTimeWithMinNotice = dayjs.utc().add(minimumBookingNotice, "minute");
|
||||||
|
|
||||||
|
@ -178,7 +179,7 @@ function buildSlotsWithDateRanges({
|
||||||
}
|
}
|
||||||
|
|
||||||
slotStartTime =
|
slotStartTime =
|
||||||
slotStartTime.utc().minute() % interval !== 0
|
slotStartTime.minute() % interval !== 0
|
||||||
? slotStartTime.startOf("hour").add(Math.ceil(slotStartTime.minute() / interval) * interval, "minute")
|
? slotStartTime.startOf("hour").add(Math.ceil(slotStartTime.minute() / interval) * interval, "minute")
|
||||||
: slotStartTime;
|
: slotStartTime;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue