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

pull/7652/merge
Efraín Rochín 2023-03-10 05:24:10 -07:00 committed by GitHub
parent 6d82e3f1b6
commit aebfc7362e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -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)));