Skip to content

Build your personal knowledge base with Trilium Notes

fix(calendar): don't use end of day for events without an end time

Glitch7521e0e50126e0c
diff --git a/apps/client/src/widgets/collections/calendar/event_builder.spec.ts b/apps/client/src/widgets/collections/calendar/event_builder.spec.ts
index 2901e1ed56..7867d35285 100644
--- a/apps/client/src/widgets/collections/calendar/event_builder.spec.ts
+++ b/apps/client/src/widgets/collections/calendar/event_builder.spec.ts
@@ -113,6 +113,19 @@ describe("Building events", () => {
expect(events[1]).toMatchObject({ title: "Note 2", start: "2025-05-07" });
});
+ it("supports events without an end time", async () => {
+ const noteIds = buildNotes([
+ { title: "Note 1", "#startDate": "2025-05-05", "#endDate": "2025-05-05", "#startTime": "13:30" },
+ ]);
+ const events = await buildEvents(noteIds);
+
+ expect(events).toHaveLength(1);
+ expect(events[0]).toMatchObject({
+ title: "Note 1",
+ start: "2025-05-05T13:30:00",
+ end: "2025-05-05"
+ });
+ });
});
describe("Promoted attributes", () => {
diff --git a/apps/client/src/widgets/collections/calendar/event_builder.ts b/apps/client/src/widgets/collections/calendar/event_builder.ts
index 4369e09ba0..8d3021b1ee 100644
--- a/apps/client/src/widgets/collections/calendar/event_builder.ts
+++ b/apps/client/src/widgets/collections/calendar/event_builder.ts
@@ -122,7 +122,7 @@ export async function buildEvent(note: FNote, { startDate, endDate, startTime, e
endDate = (endTime ? `${endDate}T${endTime}:00` : endDate);
// If the end date is now before the start date, bump it a day forward to account for times spanning the day boundary
- if (endDate && dayjs(endDate).isBefore(dayjs(startDate))) {
+ if (endDate && endTime && dayjs(endDate).isBefore(dayjs(startDate))) {
endDate = dayjs(endDate).add(1, "day").format("YYYY-MM-DDTHH:mm:ss");
}