From b5a4c71eff758d87f0cd771eaca7626af9a42ba5 Mon Sep 17 00:00:00 2001 From: TheTechnician27 Date: Thu, 16 Oct 2025 00:39:37 -0500 Subject: [PATCH] RTC: Add option to choose between system locale and yyyy-MM-dd HH:mm:ss --- pcsx2-qt/Settings/EmulationSettingsWidget.cpp | 18 +++++++++++++++--- pcsx2-qt/Settings/EmulationSettingsWidget.h | 1 + pcsx2-qt/Settings/EmulationSettingsWidget.ui | 7 +++++++ pcsx2/Config.h | 1 + pcsx2/Pcsx2Config.cpp | 2 ++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/pcsx2-qt/Settings/EmulationSettingsWidget.cpp b/pcsx2-qt/Settings/EmulationSettingsWidget.cpp index e2ef093cf3..9d96cb9165 100644 --- a/pcsx2-qt/Settings/EmulationSettingsWidget.cpp +++ b/pcsx2-qt/Settings/EmulationSettingsWidget.cpp @@ -51,7 +51,10 @@ EmulationSettingsWidget::EmulationSettingsWidget(SettingsWindow* settings_dialog m_ui.rtcDateTime->setDateRange(QDate(2000, 1, 1), QDate(2099, 12, 31)); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.manuallySetRealTimeClock, "EmuCore", "ManuallySetRealTimeClock", false); connect(m_ui.manuallySetRealTimeClock, &QCheckBox::checkStateChanged, this, &EmulationSettingsWidget::onManuallySetRealTimeClockChanged); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.rtcUseSystemLocaleFormat, "EmuCore", "UseSystemLocaleFormat", false); + connect(m_ui.rtcUseSystemLocaleFormat, &QCheckBox::checkStateChanged, this, &EmulationSettingsWidget::onUseSystemLocaleFormatChanged); EmulationSettingsWidget::onManuallySetRealTimeClockChanged(); + EmulationSettingsWidget::onUseSystemLocaleFormatChanged(); m_ui.eeCycleRate->insertItem(0, tr("Use Global Setting [%1]") @@ -159,10 +162,12 @@ EmulationSettingsWidget::EmulationSettingsWidget(SettingsWindow* settings_dialog dialog()->registerWidgetHelp(m_ui.manuallySetRealTimeClock, tr("Manually Set Real-Time Clock"), tr("Unchecked"), tr("Manually set a real-time clock to use for the virtual PlayStation 2 instead of using your OS' system clock.")); dialog()->registerWidgetHelp(m_ui.rtcDateTime, tr("Real-Time Clock"), tr("Current date and time"), - tr("Real-time clock (RTC) used by the virtual PlayStation 2. Date format is the same as the one used by your OS. " - "This time is only applied upon booting the PS2; changing it while in-game will have no effect. " - "NOTE: This assumes you have your PS2 set to the default timezone of GMT+0 and default DST of Summer Time. " + tr("Real-time clock (RTC) used by the virtual PlayStation 2.
" + "This time is only applied upon booting the PS2; changing it while in-game will have no effect.
" + "NOTE: This assumes you have your PS2 set to the default timezone of GMT+0 and default DST of Summer Time.
" "Some games require an RTC date/time set after their release date.")); + dialog()->registerWidgetHelp(m_ui.rtcUseSystemLocaleFormat, tr("Use System Locale Format"), tr("User Preference"), + tr("Uses the operating system's date/time format rather than \"yyyy-MM-dd HH:mm:ss\". May exclude seconds.")); updateOptimalFramePacing(); updateUseVSyncForTimingEnabled(); @@ -314,4 +319,11 @@ void EmulationSettingsWidget::onManuallySetRealTimeClockChanged() { const bool enabled = dialog()->getEffectiveBoolValue("EmuCore", "ManuallySetRealTimeClock", false); m_ui.rtcDateTime->setEnabled(enabled); + m_ui.rtcUseSystemLocaleFormat->setEnabled(enabled); +} + +void EmulationSettingsWidget::onUseSystemLocaleFormatChanged() +{ + const bool enabled = dialog()->getEffectiveBoolValue("EmuCore", "UseSystemLocaleFormat", false); + m_ui.rtcDateTime->setDisplayFormat(enabled ? QLocale::system().dateTimeFormat(QLocale::ShortFormat) : "yyyy-MM-dd HH:mm:ss"); } diff --git a/pcsx2-qt/Settings/EmulationSettingsWidget.h b/pcsx2-qt/Settings/EmulationSettingsWidget.h index 0af89e6ded..6472e39285 100644 --- a/pcsx2-qt/Settings/EmulationSettingsWidget.h +++ b/pcsx2-qt/Settings/EmulationSettingsWidget.h @@ -24,6 +24,7 @@ private: void updateOptimalFramePacing(); void updateUseVSyncForTimingEnabled(); void onManuallySetRealTimeClockChanged(); + void onUseSystemLocaleFormatChanged(); Ui::EmulationSettingsWidget m_ui; }; diff --git a/pcsx2-qt/Settings/EmulationSettingsWidget.ui b/pcsx2-qt/Settings/EmulationSettingsWidget.ui index 9b620c26f0..320b0a3b6f 100644 --- a/pcsx2-qt/Settings/EmulationSettingsWidget.ui +++ b/pcsx2-qt/Settings/EmulationSettingsWidget.ui @@ -266,6 +266,13 @@ + + + + Use System Locale Format + + + diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 9ad5fc1031..9b4a948f85 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -1315,6 +1315,7 @@ struct Pcsx2Config BackupSavestate : 1, McdFolderAutoManage : 1, ManuallySetRealTimeClock : 1, + UseSystemLocaleFormat : 1, // presents OS time format instead of yyyy-MM-dd HH:mm:ss for manual RTC HostFs : 1, diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 3d48bf3978..a239705293 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -1924,6 +1924,7 @@ Pcsx2Config::Pcsx2Config() WarnAboutUnsafeSettings = true; EnableDiscordPresence = false; ManuallySetRealTimeClock = false; + UseSystemLocaleFormat = false; // To be moved to FileMemoryCard pluign (someday) for (uint slot = 0; slot < 8; ++slot) @@ -1973,6 +1974,7 @@ void Pcsx2Config::LoadSaveCore(SettingsWrapper& wrap) SettingsWrapBitBool(WarnAboutUnsafeSettings); SettingsWrapBitBool(ManuallySetRealTimeClock); + SettingsWrapBitBool(UseSystemLocaleFormat); // Process various sub-components: