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

secstotimestr: use div()

parent 6e43f483
...@@ -127,23 +127,19 @@ char *mstrtime( char *psz_buffer, mtime_t date ) ...@@ -127,23 +127,19 @@ char *mstrtime( char *psz_buffer, mtime_t date )
*/ */
char *secstotimestr( char *psz_buffer, int i_seconds ) char *secstotimestr( char *psz_buffer, int i_seconds )
{ {
int i_hours, i_mins; div_t d;
i_mins = i_seconds / 60;
i_hours = i_mins / 60 ; d = div( i_seconds, 60 );
if( i_hours ) i_seconds = d.rem;
{ d = div( d.quot, 60 );
if( d.quot )
snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d", snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
(int) i_hours, d.quot, d.rem, i_seconds );
(int) (i_mins % 60),
(int) (i_seconds % 60) );
}
else else
{
snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%2.2d:%2.2d", snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%2.2d:%2.2d",
(int) i_mins , d.quot, i_seconds );
(int) (i_seconds % 60) ); return psz_buffer;
}
return( psz_buffer );
} }
#if defined (HAVE_CLOCK_NANOSLEEP) #if defined (HAVE_CLOCK_NANOSLEEP)
......
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