This commit is contained in:
philipp 2023-06-05 13:27:08 +02:00
parent 2530d6343d
commit f64128e0b1

View File

@ -208,51 +208,51 @@ 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::from(
r#"BEGIN:VCALENDAR r#"BEGIN:VCALENDAR\r\n
VERSION:2.0 VERSION:2.0\r\n
PRODID:-//rudernlinz.at//Trips//DE PRODID:-//rudernlinz.at//Trips//DE\r\n
X-WR-CALNAME:Ruderausfahrten X-WR-CALNAME:Ruderausfahrten\r\n
BEGIN:VTIMEZONE BEGIN:VTIMEZONE\r\n
TZID:Europe/Vienna TZID:Europe/Vienna\r\n
TZURL:http://tzurl.org/zoneinfo-outlook/Europe/Vienna TZURL:http://tzurl.org/zoneinfo-outlook/Europe/Vienna\r\n
X-LIC-LOCATION:Europe/Vienna X-LIC-LOCATION:Europe/Vienna\r\n
BEGIN:DAYLIGHT BEGIN:DAYLIGHT\r\n
TZOFFSETFROM:+0100 TZOFFSETFROM:+0100\r\n
TZOFFSETTO:+0200 TZOFFSETTO:+0200\r\n
TZNAME:CEST TZNAME:CEST\r\n
DTSTART:19700329T020000 DTSTART:19700329T020000\r\n
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\r\n
END:DAYLIGHT END:DAYLIGHT\r\n
BEGIN:STANDARD BEGIN:STANDARD\r\n
TZOFFSETFROM:+0200 TZOFFSETFROM:+0200\r\n
TZOFFSETTO:+0100 TZOFFSETTO:+0100\r\n
TZNAME:CET TZNAME:CET\r\n
DTSTART:19701025T030000 DTSTART:19701025T030000\r\n
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\r\n
END:STANDARD END:STANDARD\r\n
END:VTIMEZONE"#, 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"); res.push_str("\nBEGIN:VEVENT\r\n");
res.push_str(&format!("\nUID:{}@rudernlinz.at", event.id)); res.push_str(&format!("\nUID:{}@rudernlinz.at\r\n", event.id));
res.push_str(&format!( res.push_str(&format!(
"\nDTSTART;TZID=Europe/Vienna:{}T{}00", "\nDTSTART;TZID=Europe/Vienna:{}T{}00\r\n",
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", "\nDTSTAMP;TZID=Europe/Vienna:{}T{}00\r\n",
event.day.replace('-', ""), event.day.replace('-', ""),
event.planned_starting_time.replace(':', "") event.planned_starting_time.replace(':', "")
)); ));
res.push_str(&format!("\nSUMMARY:{}", event.name)); res.push_str(&format!("\nSUMMARY:{}\r\n", event.name));
res.push_str("\nEND:VEVENT"); res.push_str("\nEND:VEVENT\r\n");
} }
res.push_str("\nEND:VCALENDAR"); res.push_str("\nEND:VCALENDAR\r\n");
res res
} }
} }