From 51139a1a70af1d18e18b0804e8ce37cdd2d31c22 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Thu, 24 Jul 2025 23:35:01 +0100 Subject: [PATCH] Fix single day events showing as two days on calendar --- agenda/calendar.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/agenda/calendar.py b/agenda/calendar.py index 2dd7978..f037a3c 100644 --- a/agenda/calendar.py +++ b/agenda/calendar.py @@ -1,8 +1,8 @@ """Calendar.""" import typing -from datetime import timedelta import uuid +from datetime import timedelta from .event import Event @@ -89,7 +89,15 @@ def build_toastui_events(events: list[Event]) -> list[dict[str, typing.Any]]: if e.has_time: end_iso = (e.end_date or e.date + timedelta(minutes=30)).isoformat() else: - end_date = (e.end_as_date if e.end_date else e.as_date) + one_day + # For all-day events, the end date is exclusive. + # For a single-day event, the end date should be the same as the start date. + # For a multi-day event, a day is added to make the range inclusive. + if e.end_date: + # This is a multi-day event, so add one day to the end. + end_date = e.end_as_date + one_day + else: + # This is a single-day event. The end date is the same as the start date. + end_date = e.as_date end_iso = end_date.isoformat() item = {