@@ -2,7 +2,7 @@ use std::fs;
22use std:: path:: Path ;
33
44use anyhow:: Context as _;
5- use chrono:: { DateTime , FixedOffset } ;
5+ use chrono:: { NaiveDateTime } ;
66use serde:: Deserialize ;
77
88use crate :: generate_ics:: { EventStatus , SoonToBeIcsEvent } ;
@@ -13,8 +13,8 @@ pub struct EventEntry {
1313 pub name : String ,
1414 pub location : String ,
1515 pub description : String ,
16- pub start_time : DateTime < FixedOffset > ,
17- pub end_time : DateTime < FixedOffset > ,
16+ pub start_time : NaiveDateTime ,
17+ pub end_time : NaiveDateTime ,
1818}
1919
2020pub const FOLDER : & str = "eventfiles" ;
@@ -32,8 +32,8 @@ pub fn read(name: &str) -> anyhow::Result<Vec<EventEntry>> {
3232impl From < EventEntry > for SoonToBeIcsEvent {
3333 fn from ( event : EventEntry ) -> Self {
3434 Self {
35- start_time : event. start_time . naive_local ( ) ,
36- end_time : event. end_time . naive_local ( ) ,
35+ start_time : event. start_time ,
36+ end_time : event. end_time ,
3737 name : event. name . clone ( ) ,
3838 pretty_name : event. name ,
3939 status : EventStatus :: Confirmed ,
@@ -46,20 +46,28 @@ impl From<EventEntry> for SoonToBeIcsEvent {
4646
4747#[ test]
4848fn can_deserialize_event_entry ( ) -> Result < ( ) , serde_json:: Error > {
49+ use chrono:: NaiveDate ;
50+
4951 let test: EventEntry = serde_json:: from_str (
50- r#"{"Name": "BTI1-TI", "Location": "1060", "Description": "Dozent: HTM", "StartTime": "2022-01-13T11:40:00+01:00 ", "EndTime": "2022-01-13T12:00:00+01 :00"}"# ,
52+ r#"{"Id": "1", " Name": "BTI1-TI", "Location": "1060", "Description": "Dozent: HTM", "StartTime": "2022-01-13T11:40:00", "EndTime": "2022-01-13T12:00:00"}"# ,
5153 ) ?;
5254
5355 assert_eq ! ( test. name, "BTI1-TI" ) ;
5456 assert_eq ! ( test. location, "1060" ) ;
5557 assert_eq ! ( test. description, "Dozent: HTM" ) ;
5658 assert_eq ! (
5759 test. start_time,
58- DateTime :: parse_from_rfc3339( "2022-01-13T11:40:00+01:00" ) . unwrap( )
60+ NaiveDate :: from_ymd_opt( 2022 , 1 , 13 )
61+ . unwrap( )
62+ . and_hms_opt( 11 , 40 , 0 )
63+ . unwrap( )
5964 ) ;
6065 assert_eq ! (
6166 test. end_time,
62- DateTime :: parse_from_rfc3339( "2022-01-13T12:00:00+01:00" ) . unwrap( )
67+ NaiveDate :: from_ymd_opt( 2022 , 1 , 13 )
68+ . unwrap( )
69+ . and_hms_opt( 12 , 0 , 0 )
70+ . unwrap( )
6371 ) ;
6472
6573 Ok ( ( ) )
0 commit comments