diff options
author | stuebinm | 2022-02-02 17:52:33 +0100 |
---|---|---|
committer | stuebinm | 2022-02-02 17:52:33 +0100 |
commit | 36acf9b9e4d35dea60ef2bfe9998d09fd6a1ebef (patch) | |
tree | b0dd150ee974ed55a8d19861d9c07acb86de329b | |
parent | be7cc4ca0b7a168a9c6cd110a74d04c35956cdde (diff) |
we'll be there in -1000 minutes isn't helpful
Diffstat (limited to '')
-rw-r--r-- | src/iceportal.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 12 | ||||
-rw-r--r-- | src/types.rs | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/iceportal.rs b/src/iceportal.rs index fb5bca8..3cb5e6f 100644 --- a/src/iceportal.rs +++ b/src/iceportal.rs @@ -1,4 +1,4 @@ -use chrono::{DateTime, NaiveDateTime, Utc}; +use chrono::{DateTime, Utc}; use serde::Deserialize; use serde_json::Value; diff --git a/src/main.rs b/src/main.rs index eacbeb9..1782953 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,10 +101,15 @@ fn main() -> Result<(), ureq::Error> { match status.to_station { None => println!("{}: Fahrt ins {}", traveltext, "Blaue".blue()), - Some(to) => { + Some(to) if status.checked_in => { let now = chrono::Utc::now(); let duration = to.real_arrival().map(|dt| *dt - now); match duration { + Some(d) if d < chrono::Duration::zero() => println!( + "{}: {}", + traveltext, + "we should be there already!".green() + ), Some(d) => println!( "{}: we'll be there in {} minutes", traveltext, @@ -113,6 +118,11 @@ fn main() -> Result<(), ureq::Error> { None => println!("{}: I have no idea", traveltext) } } + Some(_to) => println!( + "{}: {}", + traveltext, + "you're not checked in".red() + ) } } Command::Checkin { from, to, train } => { diff --git a/src/types.rs b/src/types.rs index 22ba077..c1c949a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Deserializer}; -use chrono::{DateTime, Local, NaiveDateTime, Utc}; +use chrono::{DateTime, Local, Utc}; use colored::*; use crate::serde::*; @@ -122,7 +122,7 @@ pub struct Train { #[serde(rename_all = "camelCase")] pub struct Status { deprecated: bool, - checked_in: bool, + pub checked_in: bool, from_station: Station, #[serde(deserialize_with = "parse_optional_station")] pub to_station: Option<Station>, |