diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 45e0d33dff..dfb6587131 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -2,6 +2,9 @@ // by Sacha Refshauge, Megamouse and flash-fire #include +#include +#include +#include #include #include @@ -362,6 +365,16 @@ void log_q_debug(QtMsgType type, const QMessageLogContext& context, const QStrin } } +template <> +void fmt_class_string>::format(std::string& out, u64 arg) +{ + std::ostringstream ss; + const std::time_t dateTime = std::chrono::system_clock::to_time_t(get_object(arg)); + const std::tm tm = *std::localtime(&dateTime); + ss << std::put_time(&tm, "%Y-%m-%eT%H:%M:%S"); + out += ss.str(); +} + int main(int argc, char** argv) @@ -460,21 +473,24 @@ int main(int argc, char** argv) { // Write RPCS3 version logs::stored_message ver{sys_log.always()}; - ver.text = fmt::format("RPCS3 v%s | %s", rpcs3::get_version().to_string(), rpcs3::get_branch()); + ver.text = fmt::format("RPCS3 v%s | %s", rpcs3::get_version().to_string(), rpcs3::get_branch()); // Write System information logs::stored_message sys{sys_log.always()}; - sys.text = utils::get_system_info(); + sys.text = utils::get_system_info(); // Write OS version logs::stored_message os{sys_log.always()}; - os.text = utils::get_OS_version(); + os.text = utils::get_OS_version(); // Write Qt version logs::stored_message qt{(strcmp(QT_VERSION_STR, qVersion()) != 0) ? sys_log.error : sys_log.notice}; - qt.text = fmt::format("Qt version: Compiled against Qt %s | Run-time uses Qt %s", QT_VERSION_STR, qVersion()); + qt.text = fmt::format("Qt version: Compiled against Qt %s | Run-time uses Qt %s", QT_VERSION_STR, qVersion()); - logs::set_init({std::move(ver), std::move(sys), std::move(os), std::move(qt)}); + logs::stored_message time{sys_log.always()}; + time.text = fmt::format("Current Time: %s", std::chrono::system_clock::now()); + + logs::set_init({std::move(ver), std::move(sys), std::move(os), std::move(qt), std::move(time)}); } #ifdef _WIN32 diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index 76bde1ab71..bc4ee6cafb 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -2401,16 +2401,16 @@ void game_list_frame::PopulateGameList() const quint64 elapsed_ms = m_persistent_settings->GetPlaytime(serial); // Last played (support outdated values) - QDate last_played; + QDateTime last_played; const QString last_played_str = GetLastPlayedBySerial(serial); if (!last_played_str.isEmpty()) { - last_played = QDate::fromString(last_played_str, gui::persistent::last_played_date_format); + last_played = QDateTime::fromString(last_played_str, gui::persistent::last_played_date_format); if (!last_played.isValid()) { - last_played = QDate::fromString(last_played_str, gui::persistent::last_played_date_format_old); + last_played = QDateTime::fromString(last_played_str, gui::persistent::last_played_date_format_old); } } @@ -2425,7 +2425,7 @@ void game_list_frame::PopulateGameList() m_game_list->setItem(row, gui::column_resolution, new custom_table_widget_item(GetStringFromU32(game->info.resolution, localized.resolution.mode, true))); m_game_list->setItem(row, gui::column_sound, new custom_table_widget_item(GetStringFromU32(game->info.sound_format, localized.sound.format, true))); m_game_list->setItem(row, gui::column_parental, new custom_table_widget_item(GetStringFromU32(game->info.parental_lvl, localized.parental.level), Qt::UserRole, game->info.parental_lvl)); - m_game_list->setItem(row, gui::column_last_play, new custom_table_widget_item(locale.toString(last_played, gui::persistent::last_played_date_format_new), Qt::UserRole, last_played)); + m_game_list->setItem(row, gui::column_last_play, new custom_table_widget_item(locale.toString(last_played, last_played >= QDateTime::currentDateTime().addDays(-7) ? gui::persistent::last_played_date_with_time_of_day_format : gui::persistent::last_played_date_format_new), Qt::UserRole, last_played)); m_game_list->setItem(row, gui::column_playtime, new custom_table_widget_item(elapsed_ms == 0 ? tr("Never played") : localized.GetVerboseTimeByMs(elapsed_ms), Qt::UserRole, elapsed_ms)); m_game_list->setItem(row, gui::column_compat, compat_item); diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index 87b8d873a5..6db76e9233 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -449,7 +449,7 @@ void gui_application::StartPlaytime(bool start_playtime = true) return; } - m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString(gui::persistent::last_played_date_format)); + m_persistent_settings->SetLastPlayed(serial, QDateTime::currentDateTime().toString(gui::persistent::last_played_date_format)); m_timer_playtime.start(); m_timer.start(10000); // Update every 10 seconds in case the emulation crashes } @@ -471,7 +471,7 @@ void gui_application::UpdatePlaytime() } m_persistent_settings->AddPlaytime(serial, m_timer_playtime.restart()); - m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString(gui::persistent::last_played_date_format)); + m_persistent_settings->SetLastPlayed(serial, QDateTime::currentDateTime().toString(gui::persistent::last_played_date_format)); } void gui_application::StopPlaytime() @@ -489,7 +489,7 @@ void gui_application::StopPlaytime() } m_persistent_settings->AddPlaytime(serial, m_timer_playtime.restart()); - m_persistent_settings->SetLastPlayed(serial, QDate::currentDate().toString(gui::persistent::last_played_date_format)); + m_persistent_settings->SetLastPlayed(serial, QDateTime::currentDateTime().toString(gui::persistent::last_played_date_format)); m_timer_playtime.invalidate(); } diff --git a/rpcs3/rpcs3qt/persistent_settings.h b/rpcs3/rpcs3qt/persistent_settings.h index c016e99003..6c038bb657 100644 --- a/rpcs3/rpcs3qt/persistent_settings.h +++ b/rpcs3/rpcs3qt/persistent_settings.h @@ -16,9 +16,10 @@ namespace gui const QString titles = "Titles"; // Date format - const QString last_played_date_format_old = "MMMM d yyyy"; - const QString last_played_date_format_new = "MMMM d, yyyy"; - const Qt::DateFormat last_played_date_format = Qt::DateFormat::ISODate; + const QString last_played_date_format_old = "MMMM d yyyy"; + const QString last_played_date_format_new = "MMMM d, yyyy"; + const QString last_played_date_with_time_of_day_format = "MMMM d, yyyy HH:mm"; + const Qt::DateFormat last_played_date_format = Qt::DateFormat::ISODate; // GUI Saves const gui_save save_notes = gui_save(savedata, "notes", QVariantMap());