From 7cbca6ab20f34bbb9522f002f2f1cfa4eca1da18 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Tue, 28 Sep 2021 23:20:34 +0100 Subject: NOISSUE Use common duration format for global and instances --- launcher/MMCTime.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 launcher/MMCTime.cpp (limited to 'launcher/MMCTime.cpp') diff --git a/launcher/MMCTime.cpp b/launcher/MMCTime.cpp new file mode 100644 index 00000000..fa26e0b9 --- /dev/null +++ b/launcher/MMCTime.cpp @@ -0,0 +1,21 @@ +#include + +#include + +QString Time::prettifyDuration(int64_t duration) { + int seconds = (int) (duration % 60); + duration /= 60; + int minutes = (int) (duration % 60); + duration /= 60; + int hours = (int) (duration % 24); + int days = (int) (duration / 24); + if((hours == 0)&&(days == 0)) + { + return QObject::tr("%1m %2s").arg(minutes).arg(seconds); + } + if (days == 0) + { + return QObject::tr("%1h %2m").arg(hours).arg(minutes); + } + return QObject::tr("%1d %2h %3m").arg(days).arg(hours).arg(minutes); +} -- cgit