Skip to content

Scheduling infrastructure for absolutely everyone.

set isBefore or isSame to figure out the months between dates (#7649)

Efraín Rochínaebfc7362e88
diff --git a/packages/core/CalendarManager.ts b/packages/core/CalendarManager.ts
index f5f4ba36734..da20dca0c19 100644
--- a/packages/core/CalendarManager.ts
+++ b/packages/core/CalendarManager.ts
@@ -208,7 +208,12 @@ export const getBusyCalendarTimes = async (
} else {
// if dateFrom and dateTo is from different months get cache by each month
const months: string[] = [dayjs(dateFrom).format("YYYY-MM")];
- for (let i = 1; dayjs(dateFrom).add(i, "month").isBefore(dateTo); i++) {
+ for (
+ let i = 1;
+ dayjs(dateFrom).add(i, "month").isBefore(dateTo) ||
+ dayjs(dateFrom).add(i, "month").isSame(dateTo, "month");
+ i++
+ ) {
months.push(dayjs(dateFrom).add(i, "month").format("YYYY-MM"));
}
const data: EventBusyDate[][][] = await Promise.all(months.map((month) => getNextCache(username, month)));