From 8bc91262642b99b24a41cd32278750fc8b209a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arma=C3=ABl=20Gu=C3=A9neau?= Date: Mon, 15 Apr 2024 23:14:32 +0200 Subject: [PATCH] tweak duration formatting in logs --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 089a8c8..b1b81ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,15 +89,17 @@ impl fmt::Display for AlertStatus { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let days = |d: Duration| d.as_secs() / (3600 * 24); let hours = |d: Duration| (d.as_secs() / 3600) % 24; + let minutes = |d: Duration| (d.as_secs() / 60) % 60; write!( f, - "{}: inactivity: {} days, {} hours, last_alert: {}", + "{}: inactivity: {}d{}h{}m, last_alert: {}", (if self.alert { "ALERT" } else { "no alert" }), days(self.inactivity), hours(self.inactivity), + minutes(self.inactivity), match self.last_alert { None => "none".to_owned(), - Some(d) => format!("{} days, {} hours", days(d), hours(d)), + Some(d) => format!("{}d{}h{}m", days(d), hours(d), minutes(d)), } ) }