This commit is contained in:
philipp 2023-06-05 13:29:55 +02:00
parent f64128e0b1
commit 51b0ba8cf4

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