From 9770f4ef8b698cf808d009f4fee216112f68e9fd Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 28 Jan 2025 14:34:01 -0500 Subject: [PATCH] fight: also show date Shows hours if days < 0 --- packages/fight/fight.fish | 14 +++++++++++++- packages/fight/package.nix | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/fight/fight.fish b/packages/fight/fight.fish index 4e2e427..20b7f2e 100755 --- a/packages/fight/fight.fish +++ b/packages/fight/fight.fish @@ -61,5 +61,17 @@ end if [ $oldHash != $newHash ] - echo $input + set epoch (echo $data | jq -r ".locked.lastModified") # Time of last revision in Epoch time + + set then (date --date "@$epoch" --iso-8601=hours) + set now (date --date now --iso-8601=hours) + + set days (datediff $then $now -f "%d") + set hours (datediff $then $now -f "%h") + + if [ $days = 0 ] + echo "$input (from $hours hours ago)" + else + echo "$input (from $days days ago)" + end end diff --git a/packages/fight/package.nix b/packages/fight/package.nix index f8d2477..1590d9e 100644 --- a/packages/fight/package.nix +++ b/packages/fight/package.nix @@ -7,6 +7,7 @@ llakaLib.writeFishApplication [ git jq + dateutils ]; text = builtins.readFile ./fight.fish;