# HG changeset patch # User Chris Cannam # Date 1441366678 -3600 # Node ID 3ee97caa8fb6786adc70ba656d3672b21fe8787f # Parent 6c38ae0a25e58f89b1ccf3cf09af3fa265ec4b47 Fix to RealTime::toText following similar fix in SV diff -r 6c38ae0a25e5 -r 3ee97caa8fb6 src/vamp-sdk/RealTime.cpp --- 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 {