changeset 413:3ee97caa8fb6

Fix to RealTime::toText following similar fix in SV
author Chris Cannam
date Fri, 04 Sep 2015 12:37:58 +0100
parents 6c38ae0a25e5
children 6f88563ea26f
files src/vamp-sdk/RealTime.cpp
diffstat 1 files changed, 13 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/vamp-sdk/RealTime.cpp	Fri Sep 04 12:37:47 2015 +0100
+++ b/src/vamp-sdk/RealTime.cpp	Fri Sep 04 12:37:58 2015 +0100
@@ -92,7 +92,11 @@
 RealTime
 RealTime::fromSeconds(double sec)
 {
-    return RealTime(int(sec), int((sec - int(sec)) * ONE_BILLION + 0.5));
+    if (sec >= 0) {
+        return RealTime(int(sec), int((sec - int(sec)) * ONE_BILLION + 0.5));
+    } else {
+        return -fromSeconds(-sec);
+    }
 }
 
 RealTime
@@ -139,10 +143,6 @@
     std::stringstream out;
     out << *this;
     
-#if (__GNUC__ < 3)
-    out << std::ends;
-#endif
-
     std::string s = out.str();
 
     // remove trailing R
@@ -157,17 +157,19 @@
     std::stringstream out;
 
     if (sec >= 3600) {
-	out << (sec / 3600) << ":";
+        out << (sec / 3600) << ":";
     }
-
+    
     if (sec >= 60) {
-	out << (sec % 3600) / 60 << ":";
+        int minutes = (sec % 3600) / 60;
+        if (sec >= 3600 && minutes < 10) out << "0";
+        out << minutes << ":";
     }
-
+    
     if (sec >= 10) {
-	out << ((sec % 60) / 10);
+        out << ((sec % 60) / 10);
     }
-
+    
     out << (sec % 10);
     
     int ms = msec();
@@ -191,16 +193,11 @@
 	out << ".000";
     }
 	
-#if (__GNUC__ < 3)
-    out << std::ends;
-#endif
-
     std::string s = out.str();
 
     return s;
 }
 
-
 RealTime
 RealTime::operator/(int d) const
 {