summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-13 18:18:30 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-13 18:18:30 +0100
commitaa6173e254e455bdf1b7d48165fe5b595e32ebf6 (patch)
tree8ca8e8b6f8efe5e0153170c045f2cfbbda6747b8
parent932b21e2571ca76562f5901364e3fcab6093d5e8 (diff)
countdown: Added support for relative times
-rwxr-xr-xetc/functions/countdown9
1 files changed, 8 insertions, 1 deletions
diff --git a/etc/functions/countdown b/etc/functions/countdown
index c52f418..3c8bba9 100755
--- a/etc/functions/countdown
+++ b/etc/functions/countdown
@@ -7,13 +7,20 @@
autoload check_com
typeset -i beep=0
typeset -i seconds
+typeset date
if check_com beep; then
beep=1
fi
+if [[ $1 == +* ]] {
+ date=@$(($(date +%s) + ${1#+}))
+} else {
+ date="$*"
+}
+
while true; do
- seconds=$[$(date -d "$*" +%s)-$(date +%s)]
+ seconds=$[$(date -d $date +%s)-$(date +%s)]
echo -n $seconds
if (( seconds <= 0 )) {
(( beep )) && beep || echo -ne "\a"