From 5830d80c85f1cbd5b858ef57c48895a0a8d0e25d Mon Sep 17 00:00:00 2001 From: "@rtega" Date: Sun, 15 Mar 2026 12:22:01 +0100 Subject: [PATCH 1/2] Add timezone when assigning start/end time If an allday event is created and subsequently edited via khal no timezone data is added to the start and end time and thus the ics-file is not correct. ikhal does this correctly. The problem seems to be that `edit_event` doesn't add timezone data to `start` and `end` prior to calling `update_start_end`. This commit seems to solve this issue. --- fixes https://github.com/pimutils/khal/issues/1459 --- khal/controllers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/khal/controllers.py b/khal/controllers.py index 1fc2200a2..c92d697cb 100644 --- a/khal/controllers.py +++ b/khal/controllers.py @@ -580,7 +580,12 @@ def edit_event(event, collection, locale, allow_quit=False, width=80): value = prompt("datetime range", default=current) try: start, end, allday = parse_datetime.guessrangefstr(ansi.sub("", value), locale) - event.update_start_end(start, end) + if not allday: + start_loc = locale["local_timezone"].localize(start) + end_loc = locale["local_timezone"].localize(end) + event.update_start_end(start_loc, end_loc) + else: + event.update_start_end(start, end) edited = True except Exception: echo("error parsing range") From 245a517dd9269317ed00dea1a680bd4d803aade4 Mon Sep 17 00:00:00 2001 From: Marcel Schilling Date: Sun, 15 Mar 2026 12:24:53 +0100 Subject: [PATCH 2/2] Simplify @rtega's fix for issue #1459 Commit 4499e6f034d1dc31c03c4e69b292ada2d22e75c3 contains @rtega's fix suggested in https://github.com/pimutils/khal/issues/1459#issuecomment-4062572773 in verbatim, attributing them as the author. I think this commit simplifies their proposed changes without affecting the behaviour. Feel free to stash this into the above commit without acknowledging me as an author if you see fit so. --- khal/controllers.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/khal/controllers.py b/khal/controllers.py index c92d697cb..9b2b7805e 100644 --- a/khal/controllers.py +++ b/khal/controllers.py @@ -581,11 +581,9 @@ def edit_event(event, collection, locale, allow_quit=False, width=80): try: start, end, allday = parse_datetime.guessrangefstr(ansi.sub("", value), locale) if not allday: - start_loc = locale["local_timezone"].localize(start) - end_loc = locale["local_timezone"].localize(end) - event.update_start_end(start_loc, end_loc) - else: - event.update_start_end(start, end) + start = locale["local_timezone"].localize(start) + end = locale["local_timezone"].localize(end) + event.update_start_end(start, end) edited = True except Exception: echo("error parsing range")