summaryrefslogtreecommitdiffstats
path: root/bin/timekeeper
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2005-05-28 20:58:30 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2005-05-28 20:58:30 (GMT)
commite7bcc265ebdbb86007c35151630d264bd90c78b4 (patch)
tree82ffcab7ddd878004bb4c52b2cc66655d58da886 /bin/timekeeper
parent0d580697f6856de2bd0a1c394890afcbbde16d0b (diff)
downloadhdf5-e7bcc265ebdbb86007c35151630d264bd90c78b4.zip
hdf5-e7bcc265ebdbb86007c35151630d264bd90c78b4.tar.gz
hdf5-e7bcc265ebdbb86007c35151630d264bd90c78b4.tar.bz2
[svn-r10817] Purpose:
Feature Description: Add support for <time-limit> in the form of HH:MM.
Diffstat (limited to 'bin/timekeeper')
-rwxr-xr-xbin/timekeeper22
1 files changed, 21 insertions, 1 deletions
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] [<time-limit>]"
echo " Run timekeeper with <time-limit> minutes, default is $waitminutes."
+ echo " If <time-limit> 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
}