diff options
Diffstat (limited to 'src/helper.cpp')
-rw-r--r-- | src/helper.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/helper.cpp b/src/helper.cpp index 46bdf3d..e49a51b 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -1,5 +1,5 @@ /* smplayer, GUI front-end for mplayer. - Copyright (C) 2006-2014 Ricardo Villalba <rvm@users.sourceforge.net> + Copyright (C) 2006-2015 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 @@ -24,7 +24,7 @@ #include <QDir> #include <QTextCodec> #include <QWidget> -//#include <QDebug> +#include <QDebug> #include "config.h" #include "extensions.h" @@ -60,15 +60,19 @@ QString Helper::dvdForPref(const QString & dvd_id, int title) { */ QString Helper::formatTime(int secs) { + bool negative = (secs < 0); + secs = abs(secs); + int t = secs; - int hours = (int) t / 3600; - t -= hours*3600; - int minutes = (int) t / 60; - t -= minutes*60; - int seconds = t; - - QString tf; - return tf.sprintf("%02d:%02d:%02d",hours,minutes,seconds); + int hours = (int) t / 3600; + t -= hours*3600; + int minutes = (int) t / 60; + t -= minutes*60; + int seconds = t; + + //qDebug() << "Helper::formatTime:" << hours << ":" << minutes << ":" << seconds; + + 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::timeForJumps(int secs) { |