From f41426f3945ff60a26b34935bb1b0b43d8de800b Mon Sep 17 00:00:00 2001 From: Japa Date: Fri, 21 Apr 2023 00:30:38 -0300 Subject: [PATCH 1/4] Instance Description displays the last launch date Initial Draft using the Standard C++ Library, still requires testing. Signed-off-by: Japa --- launcher/minecraft/MinecraftInstance.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index af4da5d05..f9f4a56b8 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -925,7 +925,18 @@ QString MinecraftInstance::getStatusbarDescription() if(m_settings->get("ShowGameTime").toBool()) { if (lastTimePlayed() > 0) { - description.append(tr(", last played for %1").arg(Time::prettifyDuration(lastTimePlayed()))); + struct tm * localTime_format; + localTime_format = localtime(lastLaunchTime()); + + char lastLaunchTime_formatted[13]; + strftime(lastLaunchTime_formatted,13,"%Ex",localTime_format); + + description.append( + tr(", last played at %1 for %2").arg( + lastLaunchTime_formatted, + Time::prettifyDuration(lastTimePlayed()) + ) + ); } if (totalTimePlayed() > 0) { From 92cda68480f3f9bd5b5184314a2dfcdbdda7543b Mon Sep 17 00:00:00 2001 From: Japa Date: Fri, 21 Apr 2023 11:18:17 -0300 Subject: [PATCH 2/4] Update launcher/minecraft/MinecraftInstance.cpp Co-authored-by: Rachel Powers <508861+Ryex@users.noreply.github.com> Signed-off-by: Japa --- launcher/minecraft/MinecraftInstance.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index f9f4a56b8..3ab8b3af9 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -925,18 +925,10 @@ QString MinecraftInstance::getStatusbarDescription() if(m_settings->get("ShowGameTime").toBool()) { if (lastTimePlayed() > 0) { - struct tm * localTime_format; - localTime_format = localtime(lastLaunchTime()); - - char lastLaunchTime_formatted[13]; - strftime(lastLaunchTime_formatted,13,"%Ex",localTime_format); - - description.append( - tr(", last played at %1 for %2").arg( - lastLaunchTime_formatted, - Time::prettifyDuration(lastTimePlayed()) - ) - ); + QDateTime lastLaunchTime = QDateTime::fromMSecsSinceEpoch(lastLaunch()); + description.append(tr(", last played at %1 for %2") + .arg(QLocale::system().toString(lastLaunchTime, QLocale::ShortFormat)) + .arg(Time::prettifyDuration(lastTimePlayed()))); } if (totalTimePlayed() > 0) { From 672f5cf160b8630210f07d250989278f99c4e0ad Mon Sep 17 00:00:00 2001 From: Japa Date: Fri, 21 Apr 2023 19:46:33 -0300 Subject: [PATCH 3/4] Update launcher/minecraft/MinecraftInstance.cpp Co-authored-by: Sefa Eyeoglu Signed-off-by: Japa --- launcher/minecraft/MinecraftInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 3ab8b3af9..3183b41d4 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -927,7 +927,7 @@ QString MinecraftInstance::getStatusbarDescription() if (lastTimePlayed() > 0) { QDateTime lastLaunchTime = QDateTime::fromMSecsSinceEpoch(lastLaunch()); description.append(tr(", last played at %1 for %2") - .arg(QLocale::system().toString(lastLaunchTime, QLocale::ShortFormat)) + .arg(QLocale().toString(lastLaunchTime, QLocale::ShortFormat)) .arg(Time::prettifyDuration(lastTimePlayed()))); } From 7298f9c273bbfe31bf6c81af7fb6405b8baaeb13 Mon Sep 17 00:00:00 2001 From: Japa Date: Wed, 26 Apr 2023 16:06:17 -0300 Subject: [PATCH 4/4] Fixed typo Signed-off-by: Japa --- launcher/minecraft/MinecraftInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 3183b41d4..b2171a85d 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -926,7 +926,7 @@ QString MinecraftInstance::getStatusbarDescription() { if (lastTimePlayed() > 0) { QDateTime lastLaunchTime = QDateTime::fromMSecsSinceEpoch(lastLaunch()); - description.append(tr(", last played at %1 for %2") + description.append(tr(", last played on %1 for %2") .arg(QLocale().toString(lastLaunchTime, QLocale::ShortFormat)) .arg(Time::prettifyDuration(lastTimePlayed()))); }