aboutsummaryrefslogtreecommitdiff
path: root/launcher/MMCTime.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@users.noreply.github.com>2021-10-24 01:11:52 +0200
committerGitHub <noreply@github.com>2021-10-24 01:11:52 +0200
commit98887911c15dc407e797998cf04e0b90b6aa09ae (patch)
treefacb2499050ec9c6efe915987930441ae328edfc /launcher/MMCTime.cpp
parentddf98c59f5d92c07c3cbed8bd7a1eda3b6aec439 (diff)
parent5bc6dd8f970249c8279d6302f8df56910c599514 (diff)
downloadPrismLauncher-98887911c15dc407e797998cf04e0b90b6aa09ae.tar.gz
PrismLauncher-98887911c15dc407e797998cf04e0b90b6aa09ae.tar.bz2
PrismLauncher-98887911c15dc407e797998cf04e0b90b6aa09ae.zip
Merge pull request #4173 from jamierocks/common-time-duration-format
NOISSUE Use common duration format for global and instances
Diffstat (limited to 'launcher/MMCTime.cpp')
-rw-r--r--launcher/MMCTime.cpp21
1 files changed, 21 insertions, 0 deletions
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 <MMCTime.h>
+
+#include <QObject>
+
+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);
+}