From 0de6b8391fb5f5e32aafa560f4e49a8770a19a52 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Sun, 6 Aug 2023 19:21:42 +0200 Subject: [PATCH] Add stupid workaround for outlook calendars which will bite me in the ass --- src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 83d3357..5067c48 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,7 +96,18 @@ async fn convert(url: &str) -> Result { fn convert_time(dt: icalendar::DatePerhapsTime) -> Result { Ok(match dt { - icalendar::DatePerhapsTime::DateTime(cdt) => cdt.try_into_utc().ok_or(anyhow::Error::msg("failed to convert to utc"))?.timestamp(), + icalendar::DatePerhapsTime::DateTime(cdt) => { + let cdt = match cdt { + icalendar::CalendarDateTime::WithTimezone{date_time, tzid} => { + icalendar::CalendarDateTime::WithTimezone{date_time, tzid: String::from(match tzid.as_str() { + "W. Europe Standard Time" => "Europe/London", + _ => &tzid + })} + }, + _ => cdt, + }; + cdt.try_into_utc().ok_or(anyhow::Error::msg("failed to convert to utc"))?.timestamp() + }, icalendar::DatePerhapsTime::Date(nd) => nd.and_hms_opt(0, 0, 0).unwrap().timestamp(), }) }