Refactor all-day events logic

pull/2883/head
shamoon 4 months ago
parent 8e6b52f260
commit 7d8b6e2a50

@ -52,12 +52,10 @@ export default function Integration({ config, params, setEvents, hideErrors, tim
}
const eventToAdd = (date, i, type) => {
// When the 'dtend' is not defined (one-day all-day event), 'dtend' should be the same as 'dtstart'.
const { dtstart } = event;
const dtend = 'dtend' in event ? event.dtend : dtstart;
// 'dtend' is null for all-day events
const { dtstart, dtend = { value: 0 } } = event;
const duration = dtend.value - dtstart.value;
const days = duration === 0 ? 1 : duration / (1000 * 60 * 60 * 24);
const days = dtend.value === 0 ? 1 : (dtend.value - dtstart.value) / (1000 * 60 * 60 * 24);
const eventDate = timezone ? DateTime.fromJSDate(date, { zone: timezone }) : DateTime.fromJSDate(date);

Loading…
Cancel
Save