|
|
@ -8,11 +8,16 @@ usage: timer [option] [args]
|
|
|
|
-h Display this message
|
|
|
|
-h Display this message
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
max_seconds=86400
|
|
|
|
|
|
|
|
|
|
|
|
countdown() {
|
|
|
|
countdown() {
|
|
|
|
start="$(( $(date '+%s') + $1))"
|
|
|
|
start="$(( $(date '+%s') + $1))"
|
|
|
|
while [ $start -ge $(date +%s) ]; do
|
|
|
|
while [ $start -ge $(date +%s) ]; do
|
|
|
|
time="$(( $start - $(date +%s) ))"
|
|
|
|
time="$(( $start - $(date +%s) ))"
|
|
|
|
|
|
|
|
if [ $time -ge $max_seconds ]; then
|
|
|
|
|
|
|
|
echo "Maximum number of seconds ($max_seconds) for countdown surpassed."
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
|
|
|
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
|
|
|
sleep 0.1
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
done
|
|
|
@ -23,6 +28,10 @@ stopwatch() {
|
|
|
|
while true; do
|
|
|
|
while true; do
|
|
|
|
time="$(( $(date +%s) - $start))"
|
|
|
|
time="$(( $(date +%s) - $start))"
|
|
|
|
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
|
|
|
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
|
|
|
|
|
|
|
|
if [ $time -ge $max_seconds ]; then
|
|
|
|
|
|
|
|
echo "Maximum number of seconds ($max_seconds) reached."
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
sleep 0.1
|
|
|
|
sleep 0.1
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
}
|
|
|
|