From 3a2dc1f2741f7bf4d72c1cbe0fd1993af157ceaa Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Sun, 25 Feb 2024 20:50:50 +0100 Subject: Closes #5. Eta works --- src/main.rs | 6 +++--- src/requests/start.rs | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index d76341f..5a0931d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,9 +16,9 @@ mod config; mod error; mod requests; -static OVERVIEW_STYLE: &str = "{spinner:.green} ({elapsed}{wide_msg}"; -static OVERVIEW_ERROR: &str = "✗ ({elapsed}) {wide_msg}"; -static OVERVIEW_DONE: &str = "✓ ({elapsed}) {wide_msg}"; +static OVERVIEW_STYLE: &str = "{spinner:.green} ({elapsed_precise}{wide_msg}"; +static OVERVIEW_ERROR: &str = "✗ ({elapsed_precise}) {wide_msg}"; +static OVERVIEW_DONE: &str = "✓ ({elapsed_precise}) {wide_msg}"; static DEFAULT_STYLE: &str = " {spinner:.green} {wide_msg}"; static DONE_STYLE: &str = " ✓ {wide_msg}"; static ERROR_STYLE: &str = " ✗ {wide_msg}"; diff --git a/src/requests/start.rs b/src/requests/start.rs index d07177e..3afbe3a 100644 --- a/src/requests/start.rs +++ b/src/requests/start.rs @@ -121,12 +121,18 @@ async fn status_socket( } } -fn get_eta(msg: &str, uuid: &str) -> Result { +fn get_eta(msg: &str, uuid: &str) -> Result { let spl: Vec<&str> = msg.split('_').collect(); if (spl[0] != "eta") || (spl[2] != uuid) { return Err(Error::WsResponse); }; - Ok(spl[1].parse()?) + let input: u64 = spl[1].parse()?; + + let sec = input % 60; + let min = (input / 60) % 60; + let hou = (input / (60 * 60)) % 60; + + Ok(format!("{hou:0>2}:{min:0>2}:{sec:0>2}")) } fn verify_response(res: &str, org_uuid: &str) -> Result { -- cgit v1.2.3