]> git.sesse.net Git - vlc/commitdiff
Don't show h: in h:mm:ss when h is 0 in secstotimestr.
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 26 Oct 2007 04:37:38 +0000 (04:37 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 26 Oct 2007 04:37:38 +0000 (04:37 +0000)
src/misc/mtime.c

index 9a6a276760894c5a89330490263b8bb347784fb9..fc18906ce9d1fc31f2d25ae05c2fcb848451391b 100644 (file)
@@ -115,10 +115,22 @@ char *mstrtime( char *psz_buffer, mtime_t date )
  */
 char *secstotimestr( char *psz_buffer, int i_seconds )
 {
-    snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
-              (int) (i_seconds / (60 *60)),
-              (int) ((i_seconds / 60) % 60),
-              (int) (i_seconds % 60) );
+    int i_hours, i_mins;
+    i_mins = i_seconds / 60;
+    i_hours = i_mins / 60 ;
+    if( i_hours )
+    {
+        snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%d:%2.2d:%2.2d",
+                 (int) i_hours,
+                 (int) (i_mins % 60),
+                 (int) (i_seconds % 60) );
+    }
+    else
+    {
+         snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%2.2d:%2.2d",
+                   (int) i_mins ,
+                   (int) (i_seconds % 60) );
+    }
     return( psz_buffer );
 }