From: Steve Sprang <steve.sprang@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH] download: Only show hours in the elapsed time if necessary.
Date: Wed, 16 Sep 2015 20:50:52 -0700 [thread overview]
Message-ID: <CA+xn8YD64hNx9ECZYhKwuw6nhY3PFFcj8JqGwUZ++gCOvaD-Zg@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 112 bytes --]
Drop hours from the elapsed time (unless necessary) since most downloads
will be much faster than that.
-Steve
[-- Attachment #1.2: Type: text/html, Size: 154 bytes --]
[-- Attachment #2: timestamp.patch --]
[-- Type: text/x-patch, Size: 1639 bytes --]
From 5f4cafc1c0b6d261b0f19a77c64e8700784c8d9a Mon Sep 17 00:00:00 2001
From: Steve Sprang <scs@stevesprang.com>
Date: Wed, 16 Sep 2015 20:43:58 -0700
Subject: [PATCH] download: Only show hours in the elapsed time if necessary.
* guix/build/download.scm
(seconds->string): Conditionally include hours in timestamp.
---
guix/build/download.scm | 11 ++++++-----
1 file 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 "~@[~2,'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
--
2.5.0
next reply other threads:[~2015-09-17 3:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 3:50 Steve Sprang [this message]
2015-09-17 12:44 ` [PATCH] download: Only show hours in the elapsed time if necessary Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+xn8YD64hNx9ECZYhKwuw6nhY3PFFcj8JqGwUZ++gCOvaD-Zg@mail.gmail.com \
--to=steve.sprang@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.