Skip to content

Commit

Permalink
pass timezone as param
Browse files Browse the repository at this point in the history
  • Loading branch information
CarinaWolli committed Oct 4, 2024
1 parent d9c7c0c commit a1b9ccf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 8 additions & 1 deletion packages/core/bookingLimits/getBusyTimesFromLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const _getBusyTimesFromLimits = async (
duration: number | undefined,
eventType: NonNullable<EventType>,
bookings: EventBusyDetails[],
timeZone?: string | null,
rescheduleUid?: string
) => {
performance.mark("limitsStart");
Expand All @@ -45,6 +46,7 @@ const _getBusyTimesFromLimits = async (
eventTypeId: eventType.id,
limitManager,
rescheduleUid,
timeZone,
});
performance.mark("bookingLimitsEnd");
performance.measure(`checking booking limits took $1'`, "bookingLimitsStart", "bookingLimitsEnd");
Expand Down Expand Up @@ -90,6 +92,7 @@ const _getBusyTimesFromBookingLimits = async (params: {
teamId?: number;
user?: { id: number; email: string };
includeManagedEvents?: boolean;
timeZone?: string | null;
}) => {
const {
bookings,
Expand All @@ -102,6 +105,7 @@ const _getBusyTimesFromBookingLimits = async (params: {
user,
rescheduleUid,
includeManagedEvents = false,
timeZone,
} = params;

for (const key of descendingLimitKeys) {
Expand All @@ -126,6 +130,7 @@ const _getBusyTimesFromBookingLimits = async (params: {
user,
rescheduleUid,
includeManagedEvents,
timeZone,
});
} catch (_) {
limitManager.addBusyTime(periodStart, unit);
Expand Down Expand Up @@ -235,7 +240,8 @@ const _getBusyTimesFromTeamLimits = async (
dateTo: Dayjs,
teamId: number,
includeManagedEvents: boolean,
rescheduleUid?: string
rescheduleUid?: string,
timeZone?: string | null
) => {
const { limitDateFrom, limitDateTo } = getStartEndDateforLimitCheck(
dateFrom.toISOString(),
Expand Down Expand Up @@ -272,6 +278,7 @@ const _getBusyTimesFromTeamLimits = async (
teamId,
user,
includeManagedEvents,
timeZone,
});

return limitManager.getBusyTimes();
Expand Down
11 changes: 7 additions & 4 deletions packages/core/getUserAvailability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
duration,
eventType,
initialData?.busyTimesFromLimitsBookings ?? [],
initialData?.rescheduleUid ?? undefined
initialData?.rescheduleUid ?? undefined,
timeZone
)
: [];

Expand All @@ -317,7 +318,8 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA
dateTo.tz(timeZone),
teamForBookingLimits.id,
teamForBookingLimits.includeManagedEventsInLimits,
initialData?.rescheduleUid ?? undefined
initialData?.rescheduleUid ?? undefined,
timeZone
)
: [];

Expand Down Expand Up @@ -473,8 +475,9 @@ export const getPeriodStartDatesBetween = (

const _getPeriodStartDatesBetween = (dateFrom: Dayjs, dateTo: Dayjs, period: IntervalLimitUnit) => {
const dates = [];
let startDate = dayjs(dateFrom).utc().startOf(period);
const endDate = dayjs(dateTo).utc().endOf(period);
let startDate = dayjs(dateFrom).startOf(period);
const endDate = dayjs(dateTo).endOf(period);

while (startDate.isBefore(endDate)) {
dates.push(startDate);
startDate = startDate.add(1, period);
Expand Down

0 comments on commit a1b9ccf

Please sign in to comment.