fix: calendar cache date ranges (#18237)

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
Omar López
2024-12-17 19:20:19 +00:00
committed by GitHub
co-authored by Keith Williams
parent 4df4383e1e
commit ae7bbaf414
2 changed files with 3 additions and 3 deletions
@@ -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);
@@ -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();