From 84994ac347be85407834824a616baacb71937185 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 6 Aug 2023 21:23:52 +0200 Subject: [PATCH] Add special delta format case for 0 --- src/util.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util.rs b/src/util.rs index 2454657..e06b34d 100644 --- a/src/util.rs +++ b/src/util.rs @@ -25,6 +25,9 @@ pub fn time_to_offset_datetime(time: Time) -> somehow::Result { pub fn format_delta(delta: time::Duration) -> String { let seconds = delta.unsigned_abs().as_secs(); let seconds = seconds + 30 - (seconds + 30) % 60; // To nearest minute + if seconds == 0 { + return "now".to_string(); + } let formatted = humantime::format_duration(Duration::from_secs(seconds)); if delta.is_positive() { format!("in {formatted}")