add setting date and check for tomorrow

This commit is contained in:
паша душный 2023-05-29 14:49:23 +03:00
parent e94df854a3
commit e453b0db26

View File

@ -1,22 +1,23 @@
#!/usr/bin/env bash #!/usr/bin/env bash
: "${1?How to use: $0 hh mm}" : "${1?How to use: $0 hh mm [MM DD]}"
var_date=$1:$2 var_time=$1:$2
var_date=$3/$4
echo "(T)omorrow or (t)oday? " if [[ "$var_date" != "/" ]]
read -r var_day then
unix_time=$(date --date="${var_time} ${var_date}" +%s)
else
unix_time=$(date --date="${var_time}" +%s)
fi
case "$var_day" in if [[ "$unix_time" -lt $(date +%s) ]]
"T") then
var_time=$(date --date="${var_date} tomorrow" +%s) unix_time=$(date --date="${var_time} tomorrow" +%s)
;; fi
"t")
var_time=$(date --date="${var_date}" +%s)
;;
esac
while (( "$var_time" > $(date +%s) )); do while (( "$unix_time" > $(date +%s) )); do
sleep 30 sleep 30
done done