Add time-until script
All checks were successful
/ check (push) Successful in 1m36s

This commit is contained in:
Oliver Davies 2025-07-11 01:50:28 +01:00
parent 263d8e7cd3
commit 3c76e2edea
4 changed files with 30 additions and 0 deletions

View file

@ -40,6 +40,7 @@
home.packages = with pkgs; [
create-script
tag-release
time-until
todos-add
update-all-git-repos
];

View file

@ -106,6 +106,7 @@
move-firefox-screenshots
setbg
tag-release
time-until
timer
todos-add
unmounter

View file

@ -18,6 +18,7 @@ in
passmenu-otp = callPackage ./passmenu-otp.nix { };
setbg = callPackage ./setbg.nix { };
tag-release = callPackage ./tag-release.nix { };
time-until = callPackage ./time-until.nix { };
timer = callPackage ./timer.nix { };
tmux-sessionizer = callPackage ./tmux-sessionizer { };
todos-add = callPackage ./todos-add.nix { };

27
packages/time-until.nix Normal file
View file

@ -0,0 +1,27 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "time-until";
runtimeInputs = with pkgs; [ bc ];
text = ''
# Based on https://github.com/sdaschner/dotfiles/blob/master/bin/time-until.
set +o nounset
if [[ "$1" == "" ]]; then
echo "Usage: ''${0##*/} <date-string>"
echo " Example: ''${0##*/} 'tomorrow 06:00'"
exit 2
fi
set -o nounset
secsUntil=$(( $(date +%s -d "$*") - $( date +%s ) ))
minutesUntil=$(bc <<< "scale=1; $secsUntil/60")
hoursUntil=$(bc <<< "scale=2; $secsUntil/3600")
date=$(date -d "$*")
echo "$hoursUntil hours (or $minutesUntil mins) until $date"
'';
}