Commit 6d951bda authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

msecstotimestr: fix negative numbers handling

parent 820b4643
...@@ -127,6 +127,13 @@ char *mstrtime( char *psz_buffer, mtime_t date ) ...@@ -127,6 +127,13 @@ char *mstrtime( char *psz_buffer, mtime_t date )
*/ */
char *secstotimestr( char *psz_buffer, int32_t i_seconds ) char *secstotimestr( char *psz_buffer, int32_t i_seconds )
{ {
if( unlikely(i_seconds < 0) )
{
secstotimestr( psz_buffer + 1, -i_seconds );
*psz_buffer = '-';
return psz_buffer;
}
div_t d; div_t d;
d = div( i_seconds, 60 ); d = div( i_seconds, 60 );
...@@ -137,8 +144,8 @@ char *secstotimestr( char *psz_buffer, int32_t i_seconds ) ...@@ -137,8 +144,8 @@ char *secstotimestr( char *psz_buffer, int32_t i_seconds )
snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%u:%02u:%02u", snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%u:%02u:%02u",
d.quot, d.rem, i_seconds ); d.quot, d.rem, i_seconds );
else else
snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%02u:%02u", snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%02u:%02u",
d.rem, i_seconds ); d.rem, i_seconds );
return psz_buffer; return psz_buffer;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment