From d6c0c640e64fceba6c280d76ee64d44831e9afef Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 1 Feb 2022 19:40:12 +0100 Subject: handle (esp. iceportal) timestamps correctly why use unix time if you can use unix time * 1000 while your margin of error will never be lower than a full minute? --- src/iceportal.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/iceportal.rs') diff --git a/src/iceportal.rs b/src/iceportal.rs index a81d5d3..0d2076e 100644 --- a/src/iceportal.rs +++ b/src/iceportal.rs @@ -1,4 +1,4 @@ -use chrono::NaiveDateTime; +use chrono::{DateTime, NaiveDateTime, Utc}; use serde::Deserialize; use serde_json::Value; @@ -48,10 +48,10 @@ struct Station { #[derive(Deserialize, Debug)] #[serde(rename_all = "camelCase")] struct Timetable { - #[serde(deserialize_with = "option_naive_read_unixtime")] - scheduled_arrival_time: Option, - #[serde(deserialize_with = "option_naive_read_unixtime")] - actual_arrival_time: Option + #[serde(deserialize_with = "option_naive_read_unixtime_db")] + scheduled_arrival_time: Option>, + #[serde(deserialize_with = "option_naive_read_unixtime_db")] + actual_arrival_time: Option> } impl IsStation for Stop { @@ -59,12 +59,12 @@ impl IsStation for Stop { &self.station.name } - fn scheduled_arrival (&self) -> Option<&chrono::NaiveDateTime> { + fn scheduled_arrival (&self) -> Option<&chrono::DateTime> { self.timetable.scheduled_arrival_time.as_ref() } - fn real_arrival (&self) -> Option<&chrono::NaiveDateTime> { - self.timetable.actual_arrival_time.as_ref() + fn real_arrival (&self) -> Option<&chrono::DateTime> { + self.timetable.scheduled_arrival_time.as_ref() } fn ds100 (&self) -> &str { -- cgit v1.2.3