feat: date range overhaul (#9802)

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: zomars <[email protected]>
Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-07-05 09:47:41 -07:00
1 parent 9c2e15f016
commit 7b1fbd2853
10 files changed
+793 -179

No files matched your search

+14
View File
@@ -5,6 +5,7 @@ import type { Dayjs } from "@calcom/dayjs";
import dayjs from "@calcom/dayjs";
import { parseBookingLimit, parseDurationLimit } from "@calcom/lib";
import { getWorkingHours } from "@calcom/lib/availability";
import { buildDateRanges, subtract } from "@calcom/lib/date-ranges";
import { HttpError } from "@calcom/lib/http-error";
import logger from "@calcom/lib/logger";
import { checkBookingLimit } from "@calcom/lib/server";
@@ -244,9 +245,22 @@ export async function getUserAvailability(
};
});
const dateRanges = buildDateRanges({
dateFrom,
dateTo,
availability,
timeZone,
});
const formattedBusyTimes = bufferedBusyTimes.map((busy) => ({
start: dayjs(busy.start),
end: dayjs(busy.end),
}));
return {
busy: bufferedBusyTimes,
timeZone,
dateRanges: subtract(dateRanges, formattedBusyTimes),
workingHours,
dateOverrides,
currentSeats,