mirror of
https://github.com/jhbruhn/ics-adapter.git
synced 2025-03-14 19:15:50 +00:00
Implement calendar property
This commit is contained in:
parent
3d61b979c4
commit
018e219b04
1 changed files with 5 additions and 0 deletions
|
@ -33,10 +33,12 @@ struct CustomCalendarEntry {
|
|||
location: String,
|
||||
description: String,
|
||||
isallday: bool,
|
||||
calendar: u64,
|
||||
}
|
||||
|
||||
async fn convert(urls: &[&str], days: Option<&String>) -> Result<CustomCalendar> {
|
||||
let mut entries = Vec::new();
|
||||
let mut calendar_index = 0;
|
||||
for url in urls {
|
||||
let url = urlencoding::decode(url)?.into_owned();
|
||||
let ics_text = reqwest::get(url)
|
||||
|
@ -88,11 +90,14 @@ async fn convert(urls: &[&str], days: Option<&String>) -> Result<CustomCalendar>
|
|||
location: event.get_location().unwrap_or("").to_string(),
|
||||
start: start.timestamp(),
|
||||
end: end.timestamp(),
|
||||
calendar: calendar_index,
|
||||
isallday: start.time() == chrono::NaiveTime::from_hms_opt(0, 0, 0).unwrap() && end - start == chrono::Duration::days(1) // the event has a length of 24 hours and
|
||||
// starts at 00:00
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
calendar_index += 1;
|
||||
}
|
||||
|
||||
Ok(CustomCalendar{entries})
|
||||
|
|
Loading…
Reference in a new issue