Skip to content

Scheduling infrastructure for absolutely everyone.

fix: calendar cache date ranges (#18237)

Omar Lópezae7bbaf41490
diff --git a/packages/app-store/googlecalendar/lib/CalendarService.ts b/packages/app-store/googlecalendar/lib/CalendarService.ts
index 6e43f151dc3..a203a3bb3f6 100644
--- a/packages/app-store/googlecalendar/lib/CalendarService.ts
+++ b/packages/app-store/googlecalendar/lib/CalendarService.ts
@@ -724,9 +724,9 @@ export default class GoogleCalendarService implements Calendar {
async fetchAvailabilityAndSetCache(selectedCalendars: IntegrationCalendar[]) {
const parsedArgs = {
/** Expand the start date to the start of the month */
- timeMin: getTimeMax(),
+ timeMin: getTimeMin(),
/** Expand the end date to the end of the month */
- timeMax: getTimeMin(),
+ timeMax: getTimeMax(),
items: selectedCalendars.map((sc) => ({ id: sc.externalId })),
};
const data = await this.fetchAvailability(parsedArgs);
diff --git a/packages/features/calendar-cache/lib/datesForCache.ts b/packages/features/calendar-cache/lib/datesForCache.ts
index 2b900663713..6eecb0db909 100644
--- a/packages/features/calendar-cache/lib/datesForCache.ts
+++ b/packages/features/calendar-cache/lib/datesForCache.ts
@@ -9,7 +9,7 @@ export const getTimeMin = (timeMin?: string) => {
/** Expand the end date to the end of the next month */
export function getTimeMax(timeMax?: string) {
const date = timeMax ? new Date(timeMax) : new Date();
- date.setMonth(date.getMonth() + 2);
+ date.setMonth(date.getMonth() + 1);
date.setDate(0);
date.setHours(0, 0, 0, 0);
return date.toISOString();