fix(calendar): handling of start time/end time

This commit is contained in:
Elian Doran 2025-03-16 20:16:52 +02:00
parent 680729de63
commit 55ccbfe1cc
No known key found for this signature in database
2 changed files with 9 additions and 9 deletions

View File

@ -169,7 +169,7 @@ describe("Promoted attributes", () => {
const events = await CalendarView.buildEvents(noteIds);
expect(events).toHaveLength(2);
expect(events[0]).toMatchObject({ title: "Note 1", start: "2025-05-05T13:30:00", end: "2025-05-05T13:30:00" });
expect(events[0]).toMatchObject({ title: "Note 1", start: "2025-05-05T13:30:00" });
expect(events[1]).toMatchObject({ title: "Note 2", start: "2025-05-07T13:36:00", end: "2025-05-08" });
});

View File

@ -384,15 +384,15 @@ export default class CalendarView extends ViewMode {
}
for (const title of titles) {
if (endTime && !endDate) {
endDate = startDate;
}
startDate = (startTime ? `${startDate}T${startTime}:00` : startDate);
if (!endDate) {
if (!endTime) {
endDate = startDate;
} else {
const endDateOffset = CalendarView.#offsetDate(endDate ?? startDate, 1);
if (endDateOffset) {
endDate = CalendarView.#formatDateToLocalISO(endDateOffset);
}
if (!endDate && !startTime) {
const endDateOffset = CalendarView.#offsetDate(endDate ?? startDate, 1);
if (endDateOffset) {
endDate = CalendarView.#formatDateToLocalISO(endDateOffset);
}
}