diff --git a/src/utils.c b/src/utils.c
index 688f6c88f4463afc93938fe3008dca8d16794d39..8023bfb00879c67ae55abac46787fb9fc9ea58aa 100644 (file)
--- a/src/utils.c
+++ b/src/utils.c
return list;
}
-char *
-format_duration_long(unsigned long duration)
+void
+format_duration_long(char *p, size_t length, unsigned long duration)
{
const char *year = _("year");
const char *years = _("years");
const char *weeks = _("weeks");
const char *day = _("day");
const char *days = _("days");
- char *buffer, *p;
unsigned bytes_written = 0;
- unsigned length = utf8_width(years) +
- utf8_width(weeks) + utf8_width(days) + 32;
- buffer = g_malloc(length);
- p = buffer;
if (duration / 31536000 > 0) {
if (duration / 31536000 == 1)
bytes_written = g_snprintf(p, length, "%d %s, ", 1, year);
length -= bytes_written;
p += bytes_written;
}
+
g_snprintf(p, length, "%02lu:%02lu:%02lu", duration / 3600,
duration % 3600 / 60, duration % 3600 % 60);
- return buffer;
}
-
-