calcom / cal.com

Scheduling infrastructure for absolutely everyone.
https://cal.com
Other
29.83k stars 7k forks source link

[CAL-3836] Reopen: Calendar availability is not correct when an "all-day" event is used in iCal #15245

Open hactar opened 1 month ago

hactar commented 1 month ago

It looks like thie ticket https://github.com/calcom/cal.com/issues/6292 is not resolved. I too have a fully working cal.com set up with Apple iCloud calendar, yet all day events that I create using the MacOS app do not "block" the calendar, as described in the linked issue.

It also looks like a different user has narrowed the problem down to events created via the MacOS native app (see most recent comments in linked ticket.

Screenshot 2024-05-29 at 14 06 24

CAL-3836

dosubot[bot] commented 1 month ago

Hey there, @hactar! I'm a bot here to help you with bugs, questions, and becoming a contributor. I'll do my best to assist you while waiting for a human maintainer.

The issue with all-day events created using the macOS Calendar app not blocking the calendar in cal.com is known and has been reported by multiple users. There are specific considerations and potential issues related to timezone handling for all-day events, especially when the dtstart timezone is in UTC or when only tzid is available without vtimezone [1].

To address this, you might want to check the following:

  1. Timezone Handling: Ensure that the timezone information is correctly set and recognized. The code fetches the user's timezone from the database primarily for all-day events without any timezone information. If the dtstart timezone is in UTC, it is represented by "Z", but this is not recognized as UTC in ICAL.js.

  2. Adding VTIMEZONE Component: When only tzid is available without vtimezone, the code needs to add vtimezone explicitly to handle timezone differences. This involves setting the timezone offset and providing a standard dtstart.

Here is a relevant code snippet for adding the vtimezone component:

if (!vcalendar.getFirstSubcomponent("vtimezone")) {
  const timezoneToUse = tzid || userTimeZone;
  if (timezoneToUse) {
    try {
      const timezoneComp = new ICAL.Component("vtimezone");
      timezoneComp.addPropertyWithValue("tzid", timezoneToUse);
      const standard = new ICAL.Component("standard");

      const tzoffsetfrom = dayjs(event.startDate.toJSDate()).tz(timezoneToUse).format("Z");
      const tzoffsetto = dayjs(event.endDate.toJSDate()).tz(timezoneToUse).format("Z");

      standard.addPropertyWithValue("tzoffsetfrom", tzoffsetfrom);
      standard.addPropertyWithValue("tzoffsetto", tzoffsetto);
      standard.addPropertyWithValue("dtstart", "1601-01-01T00:00:00");
      timezoneComp.addSubcomponent(standard);
      vcalendar.addSubcomponent(timezoneComp);
    } catch (e) {
      console.log("error in adding vtimezone", e);
    }
  } else {
    console.error("No timezone found");
  }
}

These steps should help in diagnosing and potentially resolving the issue with all-day events created via the macOS Calendar app not blocking the calendar in cal.com [1].

#### Details **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

hactar commented 1 month ago

Attached is a screenshot from my native macos app - note that the link is principally working: cal.com created an event for me and it appeared in iCloud.

Screenshot 2024-05-29 at 14 18 49 Screenshot 2024-05-29 at 14 18 18
EduNetEurope commented 1 month ago

I seem to be experiencing the opposite issue to what @hactar described. Whereas he reported that all-day events marked as 'busy' in their MacOS app were showing up as available in cal.com, in my case, all-day events marked as 'free' in my Google sub-calendar are being incorrectly blocked off in cal.com instead of appearing as available.