Public feed #603943

Miscellany

public text v1 · immutable
Raw Edit
·published 2007-07-05 05:51 UTC
rendered paste body
Index: tovid-init.in
===================================================================
--- tovid-init.in   (revision 2149)
+++ tovid-init.in   (working copy)
@@ -172,15 +172,18 @@
 # ******************************************************************************
 function format_time()
 {
-    HMS_HOURS=$(expr $1 / 3600)
-    HMS_MINS=$(expr \( $1 % 3600 \) / 60)
-    HMS_SECS=$(expr $1 % 3600 % 60)
+    IN_SECS=${1%.*}
+    FRACTION=${1#*.}
+    FRACTION=${FRACTION:0:2}
+    HMS_HOURS=$(expr $IN_SECS / 3600)
+    HMS_MINS=$(expr \( $IN_SECS % 3600 \) / 60)
+    HMS_SECS=$(expr $IN_SECS % 3600 % 60)

     test "$HMS_HOURS" -lt 10 && HMS_HOURS="0${HMS_HOURS}"
     test "$HMS_MINS" -lt 10 && HMS_MINS="0${HMS_MINS}"
     test "$HMS_SECS" -lt 10 && HMS_SECS="0${HMS_SECS}"

-    echo "${HMS_HOURS}:${HMS_MINS}:${HMS_SECS}"
+    echo "${HMS_HOURS}:${HMS_MINS}:${HMS_SECS}.${FRACTION}"
 }

 # ******************************************************************************