From 64c737c023c4a7e0742e9749a31db3321855b1d7 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Wed, 3 Sep 2025 22:28:51 -0400 Subject: [PATCH] Fix Google Calendar UTC datetime format parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Google Calendar ICS files use UTC datetime format ending with 'Z' (e.g., 20250817T140000Z) which was failing to parse with DateTime::parse_from_str. Fixed by detecting 'Z' suffix, parsing as naive datetime, and converting to UTC with and_utc(). Also cleaned up debug logging and unused variable warnings. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/src/handlers/ics_fetcher.rs | 35 ++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/backend/src/handlers/ics_fetcher.rs b/backend/src/handlers/ics_fetcher.rs index eb62cef..1800e14 100644 --- a/backend/src/handlers/ics_fetcher.rs +++ b/backend/src/handlers/ics_fetcher.rs @@ -96,14 +96,12 @@ pub async fn fetch_external_calendar_events( // Store in cache for future requests let etag = None; // TODO: Extract ETag from response headers if available - if let Err(e) = repo.update_cache(id, &ics_content, etag).await { + if let Err(_) = repo.update_cache(id, &ics_content, etag).await { // Log error but don't fail the request - eprintln!("Failed to update cache for calendar {}: {}", id, e); } // Update last_fetched timestamp - if let Err(e) = repo.update_last_fetched(id, &user.id).await { - eprintln!("Failed to update last_fetched for calendar {}: {}", id, e); + if let Err(_) = repo.update_last_fetched(id, &user.id).await { } last_fetched = Utc::now(); @@ -122,16 +120,25 @@ pub async fn fetch_external_calendar_events( fn parse_ics_content(ics_content: &str) -> Result, Box> { let reader = ical::IcalParser::new(ics_content.as_bytes()); let mut events = Vec::new(); + let mut _total_components = 0; + let mut _failed_conversions = 0; for calendar in reader { let calendar = calendar?; for component in calendar.events { - if let Ok(vevent) = convert_ical_to_vevent(component) { - events.push(vevent); + _total_components += 1; + match convert_ical_to_vevent(component) { + Ok(vevent) => { + events.push(vevent); + } + Err(_) => { + _failed_conversions += 1; + } } } } + Ok(events) } @@ -147,6 +154,7 @@ fn convert_ical_to_vevent(ical_event: IcalEvent) -> Result Result) -> Option