fix: Issues with calendar sync at the beginning and end of month (#9282)

* increases the time range to cover all time zones

* remove console.log

---------

Co-authored-by: Omar López <[email protected]>
This commit is contained in:
Efraín RochínandOmar López authored and GitHub committed 2023-06-02 20:17:53 +00:00
1 parent 2a752e5358
commit b4eff25636
2 files changed
+15 -10

No files matched your search

+5 -1
View File
@@ -231,7 +231,11 @@ export const getBusyCalendarTimes = async (
const months = getMonths(dateFrom, dateTo);
try {
if (coldStart) {
results = await getCachedResults(withCredentials, dateFrom, dateTo, selectedCalendars);
// Subtract 11 hours from the start date to avoid problems in UTC- time zones.
const startDate = dayjs(dateFrom).subtract(11, "hours").format();
// Add 14 hours from the start date to avoid problems in UTC+ time zones.
const endDate = dayjs(dateTo).endOf("month").add(14, "hours").format();
results = await getCachedResults(withCredentials, startDate, endDate, selectedCalendars);
logger.info("Generating calendar cache in background");
// on cold start the calendar cache page generated in the background
Promise.all(months.map((month) => createCalendarCachePage(username, month)));