fix(calendar): keep the named date for all-day events - #6291
Open
JulianFriedle wants to merge 1 commit into
Open
JulianFriedle wants to merge 1 commit into
JulianFriedle wants to merge 1 commit into
Conversation
All-day events are date-only in RFC 5545, but both create paths parsed dtstart with _parse_dt_pair — which normalises tz-aware input to UTC — and then stored the row with is_utc forced to False. For a user east of UTC that turned local midnight into 22:00 the previous day, so the event read back one day early and was pushed to CalDAV as DTSTART;VALUE=DATE for the wrong date. Parse all-day values with a new _parse_date_only() that keeps the named calendar date, and resolve the effective all_day flag before parsing in both update paths, where dtstart was parsed first. Reuse the existing _ensure_positive_duration() so an all-day event sent with dtstart == dtend still spans a day instead of being dropped by the list_events overlap filter. Fixes odysseus-dev#6290
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
All-day events were stored shifted by the user's UTC offset and flagged as
local time, so they read back — and reached CalDAV — one day early. At UTC+2,
an all-day event created for 2026-10-01 landed on 2026-09-30 in Google
Calendar. This parses all-day values as the calendar date they name instead
of converting them to a UTC instant, resolves the
all_dayflag before thedatetimes in both update paths, and reuses the existing
_ensure_positive_duration()so an all-day event sent withdtstart == dtendstill spans a day.Target branch
dev, notmain.Linked Issue
Fixes #6290
Type of Change
Checklist
devdocker compose uporuvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.How to Test
Unit tests:
Four cases: a bare date, the local-midnight-with-offset form the agent path
actually emits, a zero-duration all-day event, and flipping a timed event to
all-day in a single
update_eventcall. All four fail ondevwith'2026-09-30' == '2026-10-01'and pass with this change.Neighbouring suites that touch the same code paths, all green:
python -m pytest tests/test_calendar_update_event_tz.py \ tests/test_calendar_import_zero_duration.py \ tests/test_calendar_recurrence.py \ tests/test_caldav_writeback.py -qEnd to end in the running app, user timezone UTC+2, Google calendar over
CalDAV:
docker compose up -d --buildcalendar.
Before — the agent-created event next to one synced down from Google on
the same date:
Google Calendar showed the event on 30 September.
After — same request, same timezone:
Google Calendar shows 1 October.
Visual / UI changes — REQUIRED if you touched anything that renders
Not applicable — this changes
routes/calendar_routes.pyandsrc/tools/calendar.pyonly. Nothing that renders is touched.Note for the reviewer
_parse_date_only()falls back to_parse_dt()for non-ISO input, and thathelper does its own UTC conversion. In practice all-day values never reach
the fallback, because
parse_due_for_user()normalises to ISO first — but itis worth knowing if natural-language all-day input is ever wired up.