diff options
author | TheKodeToad <TheKodeToad@proton.me> | 2023-08-16 20:46:16 +0100 |
---|---|---|
committer | TheKodeToad <TheKodeToad@proton.me> | 2023-08-16 22:23:38 +0100 |
commit | 3e2733d840d24ce4f46b49bca0b8656d4d6e3d87 (patch) | |
tree | 386113207514b8071b0122b318c10439259ca83c /launcher/MMCTime.cpp | |
parent | 57430fd189aed592a170d597de61b3acabaaa43d (diff) | |
parent | c88088c91a92a371a9bc2b7384c2897157772b7e (diff) | |
download | PrismLauncher-3e2733d840d24ce4f46b49bca0b8656d4d6e3d87.tar.gz PrismLauncher-3e2733d840d24ce4f46b49bca0b8656d4d6e3d87.tar.bz2 PrismLauncher-3e2733d840d24ce4f46b49bca0b8656d4d6e3d87.zip |
Merge branch 'develop' into better-launch
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'launcher/MMCTime.cpp')
-rw-r--r-- | launcher/MMCTime.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/launcher/MMCTime.cpp b/launcher/MMCTime.cpp index 1702ec06..3972dbd5 100644 --- a/launcher/MMCTime.cpp +++ b/launcher/MMCTime.cpp @@ -17,30 +17,29 @@ #include <MMCTime.h> -#include <QObject> #include <QDateTime> +#include <QObject> #include <QTextStream> -QString Time::prettifyDuration(int64_t duration) { - int seconds = (int) (duration % 60); +QString Time::prettifyDuration(int64_t duration) +{ + int seconds = (int)(duration % 60); duration /= 60; - int minutes = (int) (duration % 60); + int minutes = (int)(duration % 60); duration /= 60; - int hours = (int) (duration % 24); - int days = (int) (duration / 24); - if((hours == 0)&&(days == 0)) - { + int hours = (int)(duration % 24); + int days = (int)(duration / 24); + if ((hours == 0) && (days == 0)) { return QObject::tr("%1min %2s").arg(minutes).arg(seconds); } - if (days == 0) - { + if (days == 0) { return QObject::tr("%1h %2min").arg(hours).arg(minutes); } return QObject::tr("%1d %2h %3min").arg(days).arg(hours).arg(minutes); } -QString Time::humanReadableDuration(double duration, int precision) { - +QString Time::humanReadableDuration(double duration, int precision) +{ using days = std::chrono::duration<int, std::ratio<86400>>; QString outStr; @@ -48,10 +47,10 @@ QString Time::humanReadableDuration(double duration, int precision) { bool neg = false; if (duration < 0) { - neg = true; // flag - duration *= -1; // invert + neg = true; // flag + duration *= -1; // invert } - + auto std_duration = std::chrono::duration<double>(duration); auto d = std::chrono::duration_cast<days>(std_duration); std_duration -= d; @@ -78,22 +77,22 @@ QString Time::humanReadableDuration(double duration, int precision) { if (hc) { if (dc) os << " "; - os << qSetFieldWidth(2) << hc << QObject::tr("h"); // hours + os << qSetFieldWidth(2) << hc << QObject::tr("h"); // hours } if (mc) { if (dc || hc) os << " "; - os << qSetFieldWidth(2) << mc << QObject::tr("m"); // minutes + os << qSetFieldWidth(2) << mc << QObject::tr("m"); // minutes } if (dc || hc || mc || sc) { if (dc || hc || mc) os << " "; - os << qSetFieldWidth(2) << sc << QObject::tr("s"); // seconds + os << qSetFieldWidth(2) << sc << QObject::tr("s"); // seconds } if ((msc && (precision > 0)) || !(dc || hc || mc || sc)) { if (dc || hc || mc || sc) os << " "; - os << qSetFieldWidth(0) << qSetRealNumberPrecision(precision) << msc << QObject::tr("ms"); // miliseconds + os << qSetFieldWidth(0) << qSetRealNumberPrecision(precision) << msc << QObject::tr("ms"); // miliseconds } os.flush(); |