summaryrefslogtreecommitdiff
path: root/countdown2
diff options
context:
space:
mode:
authorDavid Wührer <def@raspberrypi>2019-10-13 13:25:14 +0200
committerDavid Wührer <def@raspberrypi>2019-10-13 13:25:14 +0200
commite60829f7b9c61dc870173a8dd8f2f85c17517ec4 (patch)
treee99f252f307b3a4e31df5ff45cf5daf6bccaf9f6 /countdown2
Initial commit
Diffstat (limited to 'countdown2')
-rwxr-xr-xcountdown230
1 files changed, 30 insertions, 0 deletions
diff --git a/countdown2 b/countdown2
new file mode 100755
index 0000000..615f6eb
--- /dev/null
+++ b/countdown2
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+if [ -z "$1" ]; then echo "usage $0 date"; exit 1; fi
+
+declare -ir t=`date +%s -d "$1"`;
+
+declare -i d=t-`date +%s`;
+while [ $d -gt 0 ]; do
+ #yyyy-mm-ddThh:mm:ss
+ #ww-dd hh:mm:ss
+ if [ $d -gt 5400 ]; then
+ h=$((d/3600))
+ m=$(((d-(h*3600))/60))
+ if [ $m -lt 10 ]; then m=0$m; fi
+ s=$((d%60))
+ if [ $s -lt 10 ]; then s=0$s; fi
+ echo -en "\r$h:$m:$s "
+ elif [ $d -gt 90 ]; then
+ m=$((d/60))
+ s=$((d%60))
+ if [ $s -lt 10 ]; then s=0$s; fi
+ echo -en "\r$m:$s "
+ else
+ echo -en "\r$d "
+ fi
+ #echo -en "\r$d\t";
+ sleep 1;
+ d=t-`date +%s`;
+done
+echo -en "\r"