Display events spanning more than 24h as allDay events

This commit is contained in:
Tom Hubrecht 2022-10-25 10:23:58 +02:00
parent 49d62aa749
commit 642b45f018
2 changed files with 23 additions and 4 deletions

View file

@ -56,7 +56,10 @@
</span>
<span>
{#if event.allDay}
{#if event.extendedProps.simAllDay}
<Icon name="calendar-range" class="text-primary" />
<span class="ms-1">{dateFormat(event.start)} ({timeFormat(event.extendedProps.realStart)}) - {dateFormat(event.end)} ({timeFormat(event.extendedProps.realEnd)})</span>
{:else if event.allDay}
<Icon name="calendar-range" class="text-primary" />
<span class="ms-1">{dateFormat(event.start)} - {dateFormat(event.end)}</span>
{:else}

View file

@ -132,13 +132,29 @@ function fcEventFromjCalEvent(cal) {
return function (evt) {
const start = new Date(evt.dtstart)
const end = new Date(evt.dtend)
const duration = end - start // in ms
const dayMs = 24 * 3600 * 1000
const fcEvent = {
title: `${cal.short_name ?? cal.name} : ${evt.summary}`,
start: evt.dtstart,
end: evt.dtend,
start: start,
end: end,
color: cal.color,
textColor: invertColor(cal.color),
duration: end - start // in ms
duration: duration
}
if (duration > dayMs - 1) {
fcEvent.allDay = true
fcEvent.simAllDay = true
fcEvent.realStart = new Date(start)
fcEvent.realEnd = new Date(end)
fcEvent.start.setUTCHours(0, 0, 0)
fcEvent.end.setUTCHours(23, 59, 59)
fcEvent.duration = end - start // Update the duration
}
fcEvent.calendar = cal.name