]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Make fmtTime() always include hours
authorAidan Van Dyk <aidan@ifax.com>
Mon, 26 Nov 2007 14:04:08 +0000 (14:04 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Mon, 26 Nov 2007 14:04:08 +0000 (14:04 +0000)
From Lee:
| commit 640974099533468fbbc4844d9f0f0c88f6310505
| Author: Lee Howard <faxguy@howardsilvan.com>
| Date:   Thu Nov 15 21:31:28 2007 +0000
|
|     This causes the fmtTime() time format to always include hours.
|
|     Logs like this:
|
|     JOB 1086 (sleeping dest +1234 pri 126 tts 4:58 killtime 4:58:00): SLEEP FOR 4:58
|
|     Just aren't that intuitive with respect to the "4:58".  To some readers that
|     may normally mean 4 minutes and 58 seconds... but to others it may look like
|     four hours and 58 minutes.
|
|     One such "reader" is MySQL where "4:58" will be interpreted as nearly five hours
|     instead of nearly five minutes.  In order to communicate the proper time one must
|     use "0:04:58".
|
|     So to interface things one constantly needs to parse the fmtTime()
|     output to add the hours (if not present).  Let's save everyone a headache and
|     simply always include hours to the fmtTime() time format.
|
|     JOB 1086 (sleeping dest +1234 pri 126 tts 0:04:58 killtime 4:58:00): SLEEP FOR 0:04:58
|
|     That's a lot more clear to understand.

util/FmtTime.c++

index 87adf5bd1e9be2e9e307de9b596b4e57ac4405bf..f9562bb91c729a2148be6267bba013fabad34cc2 100644 (file)
@@ -41,20 +41,18 @@ fmtTime(time_t t)
     long v;
 
     if (t < 0)
-       return ("0:00");
+       return ("0:00:00");
     if (t > 99*60*60)
        return ("??:??:??");
-    if ((v = t/3600) > 0) {
-       if (v >= 10)
-           *cp++ = digits[v / 10];
-       *cp++ = digits[v % 10];
-       *cp++ = ':';
-       t -= v*3600;
-    }
-    v = t/60;
-    if (v >= 10 || cp > tbuf)
+    v = t/3600;
+    if (v >= 10)
        *cp++ = digits[v / 10];
     *cp++ = digits[v % 10];
+    *cp++ = ':';
+    t -= v*3600;
+    v = t/60;
+    *cp++ = digits[v / 10];
+    *cp++ = digits[v % 10];
     t -= v*60;
     *cp++ = ':';
     *cp++ = digits[t / 10];