Skip to content

Build your personal knowledge base with Trilium Notes

feat(calendar): support missing end time

Elian Doran9412cfc19faa
diff --git a/src/public/app/widgets/view_widgets/calendar_view.spec.ts b/src/public/app/widgets/view_widgets/calendar_view.spec.ts
index 10ab381602..df6c8338c2 100644
--- a/src/public/app/widgets/view_widgets/calendar_view.spec.ts
+++ b/src/public/app/widgets/view_widgets/calendar_view.spec.ts
@@ -160,4 +160,17 @@ describe("Promoted attributes", () => {
expect(events[0]).toMatchObject({ title: "Note 1", start: "2025-05-05T13:36:00", end: "2025-05-05T14:56:00" });
expect(events[1]).toMatchObject({ title: "Note 2", start: "2025-05-07T13:36:00", end: "2025-05-08T14:56:00" });
});
+
+ it("handles start time with missing end time", async () => {
+ const noteIds = buildNotes([
+ { title: "Note 1", "#startDate": "2025-05-05", "#startTime": "13:30" },
+ { title: "Note 2", "#startDate": "2025-05-07", "#endDate": "2025-05-08", "#startTime": "13:36" },
+ ]);
+ 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[1]).toMatchObject({ title: "Note 2", start: "2025-05-07T13:36:00", end: "2025-05-08" });
+ });
+
});
diff --git a/src/public/app/widgets/view_widgets/calendar_view.ts b/src/public/app/widgets/view_widgets/calendar_view.ts
index 700a746150..36e4a31ef1 100644
--- a/src/public/app/widgets/view_widgets/calendar_view.ts
+++ b/src/public/app/widgets/view_widgets/calendar_view.ts
@@ -366,8 +366,9 @@ export default class CalendarView extends ViewMode {
}
for (const title of titles) {
+ startDate = (startTime ? `${startDate}T${startTime}:00` : startDate);
if (!endDate) {
- if (endTime) {
+ if (!endTime) {
endDate = startDate;
} else {
const endDateOffset = CalendarView.#offsetDate(endDate ?? startDate, 1);
@@ -377,7 +378,6 @@ export default class CalendarView extends ViewMode {
}
}
- startDate = (startTime ? `${startDate}T${startTime}:00` : startDate);
endDate = (endTime ? `${endDate}T${endTime}:00` : endDate);
const eventData: EventInput = {
title: title,