mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-11 03:38:02 +00:00
fix: calendar event created late in the evening is saved ending a day late (#32199)
Creating a calendar event after 23:00 saved it ending on the day after the date picked, so it showed on two days. The new event form pre-fills an end time one hour from now, which falls on the next day, and that next-day end date was kept even when the event was set to other times. The end date now stays on the start date when the end time is later in the day than the start time. An event that ends after midnight or spans several days keeps its end date. Fixes #31994
This commit is contained in:
parent
c2a5c7a24e
commit
69a1c57328
1 changed files with 8 additions and 1 deletions
|
|
@ -29,6 +29,7 @@
|
|||
let startTime = '';
|
||||
let endDate = '';
|
||||
let endDayOffset = 0;
|
||||
let overnight = false;
|
||||
let endTime = '';
|
||||
let allDay = false;
|
||||
let location = '';
|
||||
|
|
@ -76,6 +77,10 @@
|
|||
return new Date(`${dateStr}T${timeStr || '00:00'}`).getTime() * NS;
|
||||
}
|
||||
|
||||
function endsPastMidnight(): boolean {
|
||||
return !allDay && endTime < startTime;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
if (event) {
|
||||
title = event.title;
|
||||
|
|
@ -118,6 +123,7 @@
|
|||
(24 * 60 * 60 * 1000 * NS)
|
||||
)
|
||||
: 0;
|
||||
overnight = endDayOffset === 1 && endsPastMidnight();
|
||||
}
|
||||
|
||||
$: if (show) reset();
|
||||
|
|
@ -136,8 +142,9 @@
|
|||
loading = true;
|
||||
try {
|
||||
const startNs = dateTimeToNs(startDate, allDay ? '00:00' : startTime);
|
||||
const endDays = overnight && !endsPastMidnight() ? 0 : endDayOffset;
|
||||
const shiftedEndDate = endDate
|
||||
? nsToDateStr(dateTimeToNs(startDate, '12:00') + endDayOffset * 24 * 60 * 60 * 1000 * NS)
|
||||
? nsToDateStr(dateTimeToNs(startDate, '12:00') + endDays * 24 * 60 * 60 * 1000 * NS)
|
||||
: '';
|
||||
let endNs = shiftedEndDate
|
||||
? dateTimeToNs(shiftedEndDate, allDay ? '23:59' : endTime)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue