summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/iceportal.rs2
-rw-r--r--src/main.rs12
-rw-r--r--src/types.rs4
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>,