Skip to content

Commit

Permalink
Merge pull request #22 from Knowit-Objectnet/fixup/fjern-avvist-når-m…
Browse files Browse the repository at this point in the history
…artin-ikke-skal-på-arrangement

FIXUP: Legger til en parse-funksjon slik at Martin kan avvise arrangement uten at det kommer på skjermen
  • Loading branch information
choffa authored Oct 2, 2024
2 parents bae0b63 + 28afa1d commit 0c3cc9a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/calendar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub async fn parse_calendar(cal_to_parse: &[u8]) -> Vec<CalendarEvent> {
}

match name {
"SUMMARY" => summary = Some(value),
"SUMMARY" => summary = parse_summary(value),
"DTSTART" => start_time = parse_date(value).await,
"DTEND" => end_time = parse_date(value).await,
_ => (),
Expand Down Expand Up @@ -161,3 +161,11 @@ pub async fn parse_date(date_string: String) -> Option<DateTime<Local>> {
chrono::LocalResult::Ambiguous(a, _) => Some(a),
}
}

fn parse_summary(mut summary: String) -> Option<String> {
if summary.starts_with("Avvist: ") {
Some(summary.split_off(8))
} else {
Some(summary)
}
}

0 comments on commit 0c3cc9a

Please sign in to comment.