add setting date and check for tomorrow
This commit is contained in:
parent
e94df854a3
commit
e453b0db26
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user