From e7bcc265ebdbb86007c35151630d264bd90c78b4 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Sat, 28 May 2005 15:58:30 -0500 Subject: [svn-r10817] Purpose: Feature Description: Add support for in the form of HH:MM. --- bin/timekeeper | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bin/timekeeper b/bin/timekeeper index 278483e..aa0b21c 100755 --- a/bin/timekeeper +++ b/bin/timekeeper @@ -40,6 +40,7 @@ USAGE() { echo "Usage: %0 [-h] [-debug] []" echo " Run timekeeper with minutes, default is $waitminutes." + echo " If is in the form of HH:MM, it means wait till then." echo " -h print this help page" echo " -debug run debug mode" } @@ -58,8 +59,27 @@ ParseOption() waitminutes=1 # use shorter time for debug fi if [ $# -gt 0 ]; then - waitminutes=$1 + targettime=$1 shift + + # find out it is minutes to wait or HH:MM to wake up + case $targettime in + *:*) # HH:MM + currenttime=`date +%H:%M` + currenthour=`echo $currenttime | cut -f1 -d:` + currentminute=`echo $currenttime | cut -f2 -d:` + targethour=`echo $targettime | cut -f1 -d:` + targetminute=`echo $targettime | cut -f2 -d:` + waitminutes=`expr \( $targethour - $currenthour \) \* 60 + $targetminute - $currentminute` + if test $waitminutes -le 0; then + # target time is in tomorrow, add 1 day of minutes + waitminutes=`expr 24 \* 60 + $waitminutes` + fi + ;; + *) + waitminutes=$targettime + ;; + esac fi } -- cgit v0.12