Skip to content

Commit

Permalink
Fix all day events bleeding over to following day: (#407)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
MelissaAutumn and devmount authored May 24, 2024
1 parent 08ca6ed commit dc5d179
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions backend/src/appointment/controller/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "",
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CalendarQalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dc5d179

Please sign in to comment.