forked from qt-creator/qt-creator
Deduplicate elapsed time formatting
While it's nice to see my code spreading, I still prefer to have it at one place. Change-Id: I7bdb13c47ed7e96227deeb14b0a8070aa40148de Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
41cb713370
commit
d76a2f4fcd
@@ -30,11 +30,13 @@
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QRegularExpression>
|
||||
#include <QSet>
|
||||
#include <QTime>
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
@@ -383,4 +385,12 @@ QString quoteAmpersands(const QString &text)
|
||||
return result.replace("&", "&&");
|
||||
}
|
||||
|
||||
QString formatElapsedTime(qint64 elapsed)
|
||||
{
|
||||
elapsed += 500; // round up
|
||||
const QString format = QString::fromLatin1(elapsed >= 3600000 ? "h:mm:ss" : "mm:ss");
|
||||
const QString time = QTime(0, 0).addMSecs(elapsed).toString(format);
|
||||
return QCoreApplication::translate("StringUtils", "Elapsed time: %1.").arg(time);
|
||||
}
|
||||
|
||||
} // namespace Utils
|
||||
|
||||
Reference in New Issue
Block a user