[vlc-devel] commit: macosx/framework: Support printing negative duration. (Pierre d' Herbemont )

git version control git at videolan.org
Wed Aug 26 18:28:47 CEST 2009


vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed Aug 26 18:27:59 2009 +0200| [c1d239c0070997344522fd0ad3839f6a5a3b6fd4] | committer: Pierre d'Herbemont 

macosx/framework: Support printing negative duration.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c1d239c0070997344522fd0ad3839f6a5a3b6fd4
---

 projects/macosx/framework/Sources/VLCTime.m |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/projects/macosx/framework/Sources/VLCTime.m b/projects/macosx/framework/Sources/VLCTime.m
index 7afdeff..bccd8ea 100644
--- a/projects/macosx/framework/Sources/VLCTime.m
+++ b/projects/macosx/framework/Sources/VLCTime.m
@@ -80,15 +80,18 @@
     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
     {




More information about the vlc-devel mailing list