From 2b5fd80253d357deff6b14ca6777fd08d6fef041 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 28 Oct 2011 20:21:59 +0200 Subject: core: change format of time properties to match the OSD time format Time property values converted to strings via M_PROPERTY_PRINT resulted in a string different to what the OSD displays (if the OSD level is >= 2). Change it to match the OSD. --- m_property.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'm_property.c') diff --git a/m_property.c b/m_property.c index bbc11defa0..762ad73b7d 100644 --- a/m_property.c +++ b/m_property.c @@ -381,6 +381,16 @@ int m_property_double_ro(const m_option_t *prop, int action, return M_PROPERTY_NOT_IMPLEMENTED; } +static char *format_time(double time) +{ + int h, m, s = time; + h = s / 3600; + s -= h * 3600; + m = s / 60; + s -= m * 60; + return talloc_asprintf(NULL, "%02d:%02d:%02d", h, m, s); +} + int m_property_time_ro(const m_option_t *prop, int action, void *arg, double var) { @@ -389,17 +399,7 @@ int m_property_time_ro(const m_option_t *prop, int action, if (!arg) return M_PROPERTY_ERROR; else { - int h, m, s = var; - h = s / 3600; - s -= h * 3600; - m = s / 60; - s -= m * 60; - if (h > 0) - *(char **)arg = talloc_asprintf(NULL, "%d:%02d:%02d", h, m, s); - else if (m > 0) - *(char **)arg = talloc_asprintf(NULL, "%d:%02d", m, s); - else - *(char **)arg = talloc_asprintf(NULL, "%d", s); + *(char **)arg = format_time(var); return M_PROPERTY_OK; } } -- cgit v1.2.3