From 0688cd6653e769846a4271ac2c251a7d96249396 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 8 Mar 2022 20:07:31 -0500 Subject: include the date when formatting older timestamps --- src/format.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/format.rs b/src/format.rs index 55757c4..115ee6c 100644 --- a/src/format.rs +++ b/src/format.rs @@ -23,8 +23,16 @@ pub fn exit_status(status: std::process::ExitStatus) -> String { } pub fn time(time: time::OffsetDateTime) -> String { - let format = - time::format_description::parse("[hour]:[minute]:[second]").unwrap(); + let format = if time::OffsetDateTime::now_utc() - time + > std::time::Duration::from_secs(60 * 60 * 24) + { + time::format_description::parse( + "[year]-[month]-[day] [hour]:[minute]:[second]", + ) + .unwrap() + } else { + time::format_description::parse("[hour]:[minute]:[second]").unwrap() + }; time.format(&format).unwrap() } -- cgit v1.2.3