From: Flavio Tordini Date: Sun, 2 Aug 2015 19:53:46 +0000 (+0200) Subject: QTime seems broken on Qt5. Alternative impl. X-Git-Tag: 2.5~65 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2653784f820dfdf3520a9d0339498ac2e4b3b3e6;p=minitube QTime seems broken on Qt5. Alternative impl. --- diff --git a/src/video.cpp b/src/video.cpp index 41e8c01..3761c4d 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -473,8 +473,16 @@ QString Video::decryptSignature(const QString &s) { } QString Video::formattedDuration() const { - QString format = m_duration > 3600 ? "h:mm:ss" : "m:ss"; - return QTime().addSecs(m_duration).toString(format); + int duration = m_duration; + QString res; + int seconds = duration % 60; + duration /= 60; + int minutes = duration % 60; + duration /= 60; + int hours = duration % 24; + if (hours == 0) + return res.asprintf("%d:%02d", minutes, seconds); + return res.asprintf("%d:%02d:%02d", hours, minutes, seconds); } void Video::saveDefinitionForUrl(const QString& url, const VideoDefinition& definition) {