From 510512714df01110cf42cb2a11d944f55297c5cc Mon Sep 17 00:00:00 2001 From: Bert Date: Sat, 10 Sep 2011 18:41:20 +0200 Subject: Added slideshow support --- util.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index bc7c2e1..99166f8 100644 --- a/util.c +++ b/util.c @@ -127,8 +127,17 @@ void size_readable(float *size, const char **unit) { const char *units[] = { "", "K", "M", "G" }; int i; - for (i = 0; i < ARRLEN(units) && *size > 1024; i++) - *size /= 1024; + for (i = 0; i < ARRLEN(units) && *size > 1024.0; i++) + *size /= 1024.0; + *unit = units[MIN(i, ARRLEN(units) - 1)]; +} + +void time_readable(float *time, const char **unit) { + const char *units[] = { "s", "m", "h" }; + int i; + + for (i = 0; i < ARRLEN(units) && *time >= 60.0; i++) + *time /= 60.0; *unit = units[MIN(i, ARRLEN(units) - 1)]; } -- cgit v1.2.3