commit: b7b0034258f1a378cc3902b238bffdaca001d0f5 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Tue Feb 26 08:35:01 2019 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Wed Feb 27 20:50:10 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b7b00342
qcache: move print_seconds_for_earthlings here qcache currently is the only consumer of this function Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> qcache.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/qcache.c b/qcache.c index a3be446..831af2e 100644 --- a/qcache.c +++ b/qcache.c @@ -1,5 +1,5 @@ /* - * Copyright 2005-2018 Gentoo Foundation + * Copyright 2005-2019 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * * Copyright 2006 Thomas A. Cort - <[email protected]> @@ -677,6 +677,21 @@ qcache_dropped(qcache_data *data) free(keywords); } +static void +print_seconds_for_earthlings(const unsigned long t) +{ + unsigned dd, hh, mm, ss; + unsigned long tt = t; + ss = tt % 60; tt /= 60; + mm = tt % 60; tt /= 60; + hh = tt % 24; tt /= 24; + dd = tt; + if (dd) printf("%s%u%s day%s, ", GREEN, dd, NORM, (dd == 1 ? "" : "s")); + if (hh) printf("%s%u%s hour%s, ", GREEN, hh, NORM, (hh == 1 ? "" : "s")); + if (mm) printf("%s%u%s minute%s, ", GREEN, mm, NORM, (mm == 1 ? "" : "s")); + printf("%s%u%s second%s", GREEN, ss, NORM, (ss == 1 ? "" : "s")); +} + static void qcache_stats(qcache_data *data) {
