]> git.sesse.net Git - vlc/commitdiff
macosx/framework: Support printing negative duration.
authorPierre d'Herbemont <pdherbemont@free.fr>
Wed, 26 Aug 2009 16:27:59 +0000 (18:27 +0200)
committerPierre d'Herbemont <pdherbemont@free.fr>
Wed, 26 Aug 2009 16:28:44 +0000 (18:28 +0200)
projects/macosx/framework/Sources/VLCTime.m

index 7afdeff4d7726df1d1e90c82db0a52e4ea871652..bccd8ea1346b6fee4f71065eff34af03dd6fa719 100644 (file)
     if (value)
     {
         long long duration = [value longLongValue] / 1000000;
-        if( duration > 3600 )
-            return [NSString stringWithFormat:@"%01d:%02d:%02d",
-                (long) (duration / 3600),
-                (long)((duration / 60) % 60),
-                (long) (duration % 60)];
+        long long positiveDuration = llabs(duration);
+        if( positiveDuration > 3600 )
+            return [NSString stringWithFormat:@"%s%01d:%02d:%02d",
+                        duration < 0 ? "-" : ""
+                (long) (positiveDuration / 3600),
+                (long)((positiveDuration / 60) % 60),
+                (long) (positiveDuration % 60)];
         else
-            return [NSString stringWithFormat:@"%02d:%02d",
-                    (long)((duration / 60) % 60),
-                    (long) (duration % 60)];
+            return [NSString stringWithFormat:@"%s%02d:%02d",
+                            duration < 0 ? "-" : ""
+                    (long)((positiveDuration / 60) % 60),
+                    (long) (positiveDuration % 60)];
     }
     else
     {