From dc5d179726d8a1b5167340e2a379a57fc2fcf03d Mon Sep 17 00:00:00 2001 From: Mel <97147377+MelissaAutumn@users.noreply.github.com> Date: Fri, 24 May 2024 12:56:54 -0700 Subject: [PATCH] Fix all day events bleeding over to following day: (#407) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix all day events bleeding over to following day: * Google defines all day as "Midnight" to "Midnight + 1 day" * Subtract 1 minute from the end time. * Fix non-handling of caldav duration * ➕ Add comment for all day flag --------- Co-authored-by: Andreas Müller --- backend/src/appointment/controller/calendar.py | 15 +++++++++++---- frontend/src/components/CalendarQalendar.vue | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/src/appointment/controller/calendar.py b/backend/src/appointment/controller/calendar.py index 77ac7a451..d82c9a2fd 100644 --- a/backend/src/appointment/controller/calendar.py +++ b/backend/src/appointment/controller/calendar.py @@ -318,12 +318,19 @@ def list_events(self, start, end): # Mark tentative events tentative = status == "tentative" + title = e.vobject_instance.vevent.summary.value + start = e.vobject_instance.vevent.dtstart.value + # get_duration grabs either end or duration into a timedelta + end = start + e.get_duration() + # if start doesn't hold time information (no datetime), it's a whole day + all_day = not isinstance(start, datetime) + events.append( schemas.Event( - title=e.vobject_instance.vevent.summary.value, - start=e.vobject_instance.vevent.dtstart.value, - end=e.vobject_instance.vevent.dtend.value, - all_day=not isinstance(e.vobject_instance.vevent.dtstart.value, datetime), + title=title, + start=start, + end=end, + all_day=all_day, tentative=tentative, description=e.icalendar_component["description"] if "description" in e.icalendar_component else "", ) diff --git a/frontend/src/components/CalendarQalendar.vue b/frontend/src/components/CalendarQalendar.vue index 33a4e60a7..088d78337 100644 --- a/frontend/src/components/CalendarQalendar.vue +++ b/frontend/src/components/CalendarQalendar.vue @@ -187,7 +187,7 @@ const calendarEvents = computed(() => { ? start.format(dateFormatStrings.qalendarFullDay) : start.format(dateFormatStrings.qalendar), end: event.all_day - ? end.format(dateFormatStrings.qalendarFullDay) + ? end.subtract(1, 'minute').format(dateFormatStrings.qalendarFullDay) : end.format(dateFormatStrings.qalendar), }, description: event.description,