diff --git a/server/src/email_extract.rs b/server/src/email_extract.rs index 1fce386..1ab820b 100644 --- a/server/src/email_extract.rs +++ b/server/src/email_extract.rs @@ -421,7 +421,7 @@ mod filters { use std::io::{Cursor, Read}; use askama::Template; -use chrono::{Datelike, Local, LocalResult, NaiveDate, TimeZone, Utc}; +use chrono::{Datelike, Local, LocalResult, TimeZone, Utc}; use chrono_tz::Tz; use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail}; use quick_xml::de::from_str as xml_from_str; @@ -1889,8 +1889,7 @@ pub fn render_ical_summary(ical_data: &str) -> Result { }; // Generate event days for the recurrence - let mut cur = start.date_naive(); - let mut n = 0; + let cur = start.date_naive(); let max_span = 366; // safety: don't generate more than a year let mut weekday_set = HashSet::new(); if let Some(ref byday_vec) = byday { @@ -2052,50 +2051,6 @@ pub fn render_ical_summary(ical_data: &str) -> Result { let local_fmt_end_val = &local_fmt_end; let description_paragraphs_val = &description_paragraphs; // Compute calendar grid for template rendering - let (all_days, caption) = if !event_days.is_empty() { - let first_event = event_days.first().unwrap(); - let last_event = event_days.last().unwrap(); - let first_of_month = - chrono::NaiveDate::from_ymd_opt(first_event.year(), first_event.month(), 1) - .unwrap(); - let last_of_month = { - let next_month = if last_event.month() == 12 { - chrono::NaiveDate::from_ymd_opt(last_event.year() + 1, 1, 1).unwrap() - } else { - chrono::NaiveDate::from_ymd_opt( - last_event.year(), - last_event.month() + 1, - 1, - ) - .unwrap() - }; - next_month.pred_opt().unwrap() - }; - let mut cal_start = first_of_month; - while cal_start.weekday() != chrono::Weekday::Sun { - cal_start = cal_start.pred_opt().unwrap(); - } - let mut cal_end = last_of_month; - while cal_end.weekday() != chrono::Weekday::Sat { - cal_end = cal_end.succ_opt().unwrap(); - } - let mut all_days = vec![]; - let mut d = cal_start; - while d <= cal_end { - all_days.push(d); - d = d.succ_opt().unwrap(); - } - let start_month = first_event.format("%B %Y"); - let end_month = last_event.format("%B %Y"); - let caption = if start_month.to_string() == end_month.to_string() { - start_month.to_string() - } else { - format!("{} – {}", start_month, end_month) - }; - (all_days, caption) - } else { - (vec![], String::new()) - }; let template = IcalSummaryTemplate { summary: summary_val, local_fmt_start: local_fmt_start_val,