Fix all-day event end date handling by removing double conversion

Root cause: Both frontend and backend were adding a day for all-day events:
- Frontend: Converts inclusive UI dates (9/22-9/25) to exclusive (9/22-9/26)
- Backend: Was incorrectly adding another day (9/22-9/27) causing display issues

Fixed by:
- Remove duplicate day addition in backend handlers (events.rs, series.rs)
- Keep frontend conversion for proper RFC 5545 compliance
- Add reverse conversion when loading events for editing
- Maintain user-friendly inclusive dates in UI while storing exclusive dates

Now properly handles: UI 9/22-9/25 ↔ Storage 9/22-9/26 (exclusive per spec)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Connor Johnstone
2025-09-21 12:34:09 -04:00
parent 5c406569af
commit cb1bb23132
4 changed files with 19 additions and 20 deletions

View File

@@ -257,7 +257,13 @@ fn vevent_to_creation_data(event: &crate::models::ical::VEvent, available_calend
// Timing
start_date: start_local.date(),
end_date: end_local.date(),
end_date: if event.all_day {
// For all-day events, subtract one day to convert from exclusive to inclusive end date
// (UI expects inclusive dates, but iCalendar stores exclusive end dates)
end_local.date() - chrono::Duration::days(1)
} else {
end_local.date()
},
start_time: start_local.time(),
end_time: end_local.time(),

View File

@@ -156,8 +156,9 @@ impl EventCreationData {
) {
// Use local date/times and timezone - no UTC conversion
let effective_end_date = if self.end_time == NaiveTime::from_hms_opt(0, 0, 0).unwrap() {
// If end time is midnight (00:00), treat it as beginning of next day
let effective_end_date = if self.all_day {
// For all-day events, add one day to convert from inclusive to exclusive end date
// (iCalendar spec requires exclusive end dates for all-day events)
self.end_date + chrono::Duration::days(1)
} else {
self.end_date