summaryrefslogtreecommitdiff
path: root/src/iceportal.rs
diff options
context:
space:
mode:
authorstuebinm2022-02-01 19:40:12 +0100
committerstuebinm2022-02-01 19:40:12 +0100
commitd6c0c640e64fceba6c280d76ee64d44831e9afef (patch)
tree199582ce5622c5a7593666a0e1799cdb68e96968 /src/iceportal.rs
parent80a4af9f0a6f7e3bd2d8254f8bc8475ca73b8980 (diff)
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?
Diffstat (limited to 'src/iceportal.rs')
-rw-r--r--src/iceportal.rs16
1 files changed, 8 insertions, 8 deletions
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<NaiveDateTime>,
- #[serde(deserialize_with = "option_naive_read_unixtime")]
- actual_arrival_time: Option<NaiveDateTime>
+ #[serde(deserialize_with = "option_naive_read_unixtime_db")]
+ scheduled_arrival_time: Option<DateTime<Utc>>,
+ #[serde(deserialize_with = "option_naive_read_unixtime_db")]
+ actual_arrival_time: Option<DateTime<Utc>>
}
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<Utc>> {
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<Utc>> {
+ self.timetable.scheduled_arrival_time.as_ref()
}
fn ds100 (&self) -> &str {