From 13a752a69cf18131968e4a7d3395bb0d1baa1eaf Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Wed, 3 Sep 2025 16:21:24 -0400 Subject: [PATCH] Fix timezone bug in event drag-and-drop causing 4-hour offset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Events dragged to 4am-7am were appearing at 8am-11am due to double timezone conversion. The issue was: 1. Frontend converted local time to UTC before sending to backend 2. Backend (after previous fix) converted "local time" (actually UTC) to UTC again 3. Result: double conversion causing 4+ hour shift in wrong direction Solution: Remove frontend UTC conversion in drag-and-drop callback. Let backend handle the local-to-UTC conversion consistently. - Remove .and_local_timezone(chrono::Local).unwrap().to_utc() conversion - Send NaiveDateTime directly as local time strings to backend - Backend parse_event_datetime() now properly handles local-to-UTC conversion Now drag-and-drop works correctly: drag to 4am shows 4am. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/src/app.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/frontend/src/app.rs b/frontend/src/app.rs index 24c113c..b7afe13 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -548,18 +548,11 @@ pub fn App() -> Html { String::new() }; - // Convert local times to UTC for backend storage - let start_utc = new_start - .and_local_timezone(chrono::Local) - .unwrap() - .to_utc(); - let end_utc = new_end.and_local_timezone(chrono::Local).unwrap().to_utc(); - - // Format UTC date and time strings for backend - let start_date = start_utc.format("%Y-%m-%d").to_string(); - let start_time = start_utc.format("%H:%M").to_string(); - let end_date = end_utc.format("%Y-%m-%d").to_string(); - let end_time = end_utc.format("%H:%M").to_string(); + // Send local time directly to backend (backend will handle UTC conversion) + let start_date = new_start.format("%Y-%m-%d").to_string(); + let start_time = new_start.format("%H:%M").to_string(); + let end_date = new_end.format("%Y-%m-%d").to_string(); + let end_time = new_end.format("%H:%M").to_string(); // Convert existing event data to string formats for the API let status_str = match original_event.status {