guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/01: download: Only show hours in the elapsed time if necessary.


From: Ludovic Courtès
Subject: 01/01: download: Only show hours in the elapsed time if necessary.
Date: Thu, 17 Sep 2015 12:44:16 +0000

civodul pushed a commit to branch master
in repository guix.

commit 47770296d2343a8f3bcd3082d09fbfbcef0857ae
Author: Steve Sprang <address@hidden>
Date:   Wed Sep 16 20:43:58 2015 -0700

    download: Only show hours in the elapsed time if necessary.
    
    * guix/build/download.scm
      (seconds->string): Conditionally include hours in timestamp.
    
    Signed-off-by: Ludovic Courtès <address@hidden>
---
 guix/build/download.scm |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/guix/build/download.scm b/guix/build/download.scm
index 9b72e8f..d362fc1 100644
--- a/guix/build/download.scm
+++ b/guix/build/download.scm
@@ -63,16 +63,17 @@ object, as an inexact number."
      (/ (time-nanosecond duration) 1e9)))
 
 (define (seconds->string duration)
-  "Given DURATION in seconds, return a string representing it in 'hh:mm:ss'
-format."
+  "Given DURATION in seconds, return a string representing it in 'mm:ss' or
+'hh:mm:ss' format, as needed."
   (if (not (number? duration))
-      "00:00:00"
+      "00:00"
       (let* ((total-seconds (nearest-exact-integer duration))
              (extra-seconds (modulo total-seconds 3600))
-             (hours         (quotient total-seconds 3600))
+             (num-hours     (quotient total-seconds 3600))
+             (hours         (and (positive? num-hours) num-hours))
              (mins          (quotient extra-seconds 60))
              (secs          (modulo extra-seconds 60)))
-        (format #f "~2,'0d:~2,'0d:~2,'0d" hours mins secs))))
+        (format #f "address@hidden,'0d:~]~2,'0d:~2,'0d" hours mins secs))))
 
 (define (byte-count->string size)
   "Given SIZE in bytes, return a string representing it in a human-readable



reply via email to

[Prev in Thread] Current Thread [Next in Thread]