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
: "${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? "
read -r var_day
if [[ "$var_date" != "/" ]]
then
unix_time=$(date --date="${var_time} ${var_date}" +%s)
else
unix_time=$(date --date="${var_time}" +%s)
fi
case "$var_day" in
"T")
var_time=$(date --date="${var_date} tomorrow" +%s)
;;
"t")
var_time=$(date --date="${var_date}" +%s)
;;
esac
if [[ "$unix_time" -lt $(date +%s) ]]
then
unix_time=$(date --date="${var_time} tomorrow" +%s)
fi
while (( "$var_time" > $(date +%s) )); do
while (( "$unix_time" > $(date +%s) )); do
sleep 30
done