[vlc-devel] commit: secstotimestr: use div() ( Rémi Denis-Courmont )
git version control
git at videolan.org
Thu Feb 18 22:18:47 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Feb 18 23:18:27 2010 +0200| [e8f2c68830e2bdd09517cad836d9a1d35bcc1881] | committer: Rémi Denis-Courmont
secstotimestr: use div()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e8f2c68830e2bdd09517cad836d9a1d35bcc1881
---
src/misc/mtime.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/src/misc/mtime.c b/src/misc/mtime.c
index 454e99f..8905be4 100644
--- a/src/misc/mtime.c
+++ b/src/misc/mtime.c
@@ -127,23 +127,19 @@ char *mstrtime( char *psz_buffer, mtime_t date )
*/
char *secstotimestr( char *psz_buffer, int i_seconds )
{
- int i_hours, i_mins;
- i_mins = i_seconds / 60;
- i_hours = i_mins / 60 ;
- if( i_hours )
- {
+ div_t d;
+
+ d = div( i_seconds, 60 );
+ i_seconds = d.rem;
+ d = div( d.quot, 60 );
+
+ if( d.quot )
snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
- (int) i_hours,
- (int) (i_mins % 60),
- (int) (i_seconds % 60) );
- }
+ d.quot, d.rem, i_seconds );
else
- {
snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%2.2d:%2.2d",
- (int) i_mins ,
- (int) (i_seconds % 60) );
- }
- return( psz_buffer );
+ d.quot, i_seconds );
+ return psz_buffer;
}
#if defined (HAVE_CLOCK_NANOSLEEP)
More information about the vlc-devel
mailing list