diff --git a/lib/slots.ts b/lib/slots.ts index d7cd3031ae..98bc7551b0 100644 --- a/lib/slots.ts +++ b/lib/slots.ts @@ -17,11 +17,11 @@ export type GetSlots = { minimumBookingNotice: number; }; -const getMinuteOffset = (date: Dayjs, step: number) => { +const getMinuteOffset = (date: Dayjs, frequency: number) => { // Diffs the current time with the given date and iff same day; (handled by 1440) - return difference; otherwise 0 - const minuteOffset = Math.min(date.diff(dayjs.utc().startOf("day"), "minute"), 1440) % 1440; + const minuteOffset = Math.min(date.diff(dayjs().utc(), "minute"), 1440) % 1440; // round down to nearest step - return Math.ceil(minuteOffset / step) * step; + return Math.ceil(minuteOffset / frequency) * frequency; }; // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/test/lib/slots.test.ts b/test/lib/slots.test.ts index cae7976ccf..4377f95da3 100644 --- a/test/lib/slots.test.ts +++ b/test/lib/slots.test.ts @@ -16,7 +16,7 @@ it("can fit 24 hourly slots for an empty day", async () => { // 24h in a day. expect( getSlots({ - inviteeDate: dayjs.utc().add(1, "day").startOf("day"), + inviteeDate: dayjs.utc().add(1, "day"), frequency: 60, minimumBookingNotice: 0, workingHours: [