diff options
Diffstat (limited to 'src/helper.cpp')
-rw-r--r-- | src/helper.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/helper.cpp b/src/helper.cpp index fc3bdd7..fdcbb18 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -61,7 +61,7 @@ QString Helper::dvdForPref(const QString & dvd_id, int title) { QString Helper::formatTime(int secs) { bool negative = (secs < 0); - secs = abs(secs); + secs = qAbs(secs); int t = secs; int hours = (int) t / 3600; @@ -75,6 +75,24 @@ QString Helper::formatTime(int secs) { return QString("%1%2:%3:%4").arg(negative ? "-" : "").arg(hours, 2, 10, QChar('0')).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0')); } +QString Helper::formatTime2(double secs) { + bool negative = (secs < 0); + secs = qAbs(secs); + + double t = secs; + int hours = (int) t / 3600; + t -= hours*3600; + int minutes = (int) t / 60; + t -= minutes*60; + int seconds = t; + t -= seconds; + int milliseconds = t*1000; + + //qDebug() << "Helper::formatTime: secs:" << secs << "=" << hours << ":" << minutes << ":" << seconds << "." << milliseconds; + + return QString("%1%2:%3:%4.%5").arg(negative ? "-" : "").arg(hours, 2, 10, QChar('0')).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0')).arg(milliseconds, 3, 10, QChar('0')); +} + QString Helper::timeForJumps(int secs) { int minutes = (int) secs / 60; int seconds = secs % 60; |