This commit is contained in:
philipp 2023-06-05 14:07:46 +02:00
parent a72e19d8e1
commit b6057f066d

View File

@ -207,52 +207,28 @@ FROM user_trip WHERE trip_details_id = (SELECT trip_details_id FROM planned_even
} }
pub async fn get_ics_feed(db: &SqlitePool) -> String { pub async fn get_ics_feed(db: &SqlitePool) -> String {
let mut res = String::from( let mut res = String::new();
"BEGIN:VCALENDAR\r\n res.push_str("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//rudernlinz.at//Trips//DE\r\nX-WR-CALNAME:Ruderausfahrten\r\nBEGIN:VTIMEZONE\r\nTZID:Europe/Vienna\r\nTZURL:http://tzurl.org/zoneinfo-outlook/Europe/Vienna\r\nX-LIC-LOCATION:Europe/Vienna\r\nBEGIN:DAYLIGHT\r\nTZOFFSETFROM:+0100\r\nTZOFFSETTO:+0200\r\nTZNAME:CEST\r\nDTSTART:19700329T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\nEND:DAYLIGHT\r\nBEGIN:STANDARD\r\nTZOFFSETFROM:+0200\r\nTZOFFSETTO:+0100\r\nTZNAME:CET\r\nDTSTART:19701025T030000\r\nRRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\nEND:STANDARD\r\nEND:VTIMEZONE");
VERSION:2.0\r\n
PRODID:-//rudernlinz.at//Trips//DE\r\n
X-WR-CALNAME:Ruderausfahrten\r\n
BEGIN:VTIMEZONE\r\n
TZID:Europe/Vienna\r\n
TZURL:http://tzurl.org/zoneinfo-outlook/Europe/Vienna\r\n
X-LIC-LOCATION:Europe/Vienna\r\n
BEGIN:DAYLIGHT\r\n
TZOFFSETFROM:+0100\r\n
TZOFFSETTO:+0200\r\n
TZNAME:CEST\r\n
DTSTART:19700329T020000\r\n
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\n
END:DAYLIGHT\r\n
BEGIN:STANDARD\r\n
TZOFFSETFROM:+0200\r\n
TZOFFSETTO:+0100\r\n
TZNAME:CET\r\n
DTSTART:19701025T030000\r\n
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\n
END:STANDARD\r\n
END:VTIMEZONE",
);
let events = PlannedEvent::all(db).await; let events = PlannedEvent::all(db).await;
for event in events { for event in events {
res.push_str("\nBEGIN:VEVENT\r\n"); res.push_str("\r\nBEGIN:VEVENT");
res.push_str(&format!("\nUID:{}@rudernlinz.at\r\n", event.id)); res.push_str(&format!("\r\nUID:{}@rudernlinz.at", event.id));
res.push_str(&format!( res.push_str(&format!(
"\nDTSTART;TZID=Europe/Vienna:{}T{}00\r\n", "\r\nDTSTART;TZID=Europe/Vienna:{}T{}00",
event.day.replace('-', ""), event.day.replace('-', ""),
event.planned_starting_time.replace(':', "") event.planned_starting_time.replace(':', "")
)); ));
res.push_str(&format!( res.push_str(&format!(
"\nDTSTAMP;TZID=Europe/Vienna:{}T{}00\r\n", "\r\nDTSTAMP;TZID=Europe/Vienna:{}T{}00",
event.day.replace('-', ""), event.day.replace('-', ""),
event.planned_starting_time.replace(':', "") event.planned_starting_time.replace(':', "")
)); ));
res.push_str(&format!("\nSUMMARY:{}\r\n", event.name)); res.push_str(&format!("\r\nSUMMARY:{}", event.name));
res.push_str("\r\nEND:VEVENT");
res.push_str("\nEND:VEVENT\r\n");
} }
res.push_str("\nEND:VCALENDAR\r\n"); res.push_str("\r\nEND:VCALENDAR");
res res
} }
} }