diff options
author | wm4 <wm4@nowhere> | 2012-09-01 21:59:13 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-09-18 21:04:47 +0200 |
commit | 53bfaecd40aa7b34dcc9c90064e36f2ffe227fc0 (patch) | |
tree | 7c8865437d2e48d1c9782c37520d04d3e0604dca /mpcommon.c | |
parent | 5a13f5a5e8dd63c899581db86c51c9bb093fcdde (diff) | |
download | mpv-53bfaecd40aa7b34dcc9c90064e36f2ffe227fc0.tar.bz2 mpv-53bfaecd40aa7b34dcc9c90064e36f2ffe227fc0.tar.xz |
core: remove duplicated format_time() functions
This was an on-going transition to make mplayer format all times in the
same format.
Diffstat (limited to 'mpcommon.c')
-rw-r--r-- | mpcommon.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mpcommon.c b/mpcommon.c index b6e618742e..d4811440aa 100644 --- a/mpcommon.c +++ b/mpcommon.c @@ -15,3 +15,22 @@ * with MPlayer; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#include "talloc.h" +#include "mpcommon.h" + +char *mp_format_time(double time, bool fractions) +{ + if (time < 0) + return talloc_strdup(NULL, "unknown"); + int h, m, s = time; + h = s / 3600; + s -= h * 3600; + m = s / 60; + s -= m * 60; + char *res = talloc_asprintf(NULL, "%02d:%02d:%02d", h, m, s); + if (fractions) + res = talloc_asprintf_append(res, ".%03d", + (int)((time - (int)time) * 1000)); + return res; +} |