Update to allow next-day times

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-01-12 19:03:16 +01:00
parent 801f0ff65c
commit a824953ded
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -7,6 +7,7 @@ time=${1:-}
[ -z "${time}" ] && fail "No time specified" [ -z "${time}" ] && fail "No time specified"
tdiff=$(($(date -d "$1" +%s) - $(date +%s))) tdiff=$(($(date -d "$1" +%s) - $(date +%s)))
step "Sleeping ${tdiff}s until ${time}..." [ $tdiff -gt 0 ] || tdiff=$((tdiff + 86400))
step "Sleeping ${tdiff}s until $(date -d "now + ${tdiff} seconds" "+%Y-%m-%d %H:%M:%S")..."
sleep ${tdiff} sleep ${tdiff}