From da7ef0f4796805f1abb11c7767e796f46ed9de3b Mon Sep 17 00:00:00 2001 From: Ollo Date: Fri, 15 Sep 2023 19:19:35 +0200 Subject: [PATCH] Test time handling --- client/bin/src/straba.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/bin/src/straba.rs b/client/bin/src/straba.rs index c5f1f92..4c8c217 100644 --- a/client/bin/src/straba.rs +++ b/client/bin/src/straba.rs @@ -102,14 +102,21 @@ pub fn fetch_data() -> Option<&'static str> { } let cur_time = DateTime::::default(); + + NaiveDateTime::default().and_utc() + println!("Next results after {:?}", cur_time); // parse JSON result.. search of both directions let json = body.unwrap(); for el in (json.graphQL.response.journeys.elements) { println!("Line {:}", el.line.lineGroup.label); for stop in el.stops { if stop.realtimeDeparture.isoString.is_some() { - println!("To {:} {:?}", stop.destinationLabel, stop.realtimeDeparture.isoString) + let txt_departure = stop.realtimeDeparture.isoString.unwrap(); + let next_departure = DateTime::parse_from_rfc3339(&txt_departure); + if (next_departure.unwrap() > cur_time) { + println!("To {:} {:}", stop.destinationLabel, txt_departure); + } } else { println!("Planned {:} {:?}", stop.destinationLabel, stop.plannedDeparture.isoString) }