aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-09-10 18:41:20 +0200
committerBert <ber.t@gmx.com>2011-09-10 18:41:20 +0200
commit510512714df01110cf42cb2a11d944f55297c5cc (patch)
tree38a7393df90254e9d89e80c37c9ae4a16eb58b6b /util.c
parent79d780a701e47ea1aacf49728e28900bb2b17743 (diff)
downloadnsxiv-510512714df01110cf42cb2a11d944f55297c5cc.tar.zst
Added slideshow support
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 11 insertions, 2 deletions
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)];
}