Skip to content

Commit 95cb4b4

Browse files
RTC: Add option to choose between system locale and yyyy-MM-dd HH:mm:ss
1 parent 5549876 commit 95cb4b4

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

pcsx2-qt/Settings/EmulationSettingsWidget.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ EmulationSettingsWidget::EmulationSettingsWidget(SettingsWindow* settings_dialog
5151
m_ui.rtcDateTime->setDateRange(QDate(2000, 1, 1), QDate(2099, 12, 31));
5252
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.manuallySetRealTimeClock, "EmuCore", "ManuallySetRealTimeClock", false);
5353
connect(m_ui.manuallySetRealTimeClock, &QCheckBox::checkStateChanged, this, &EmulationSettingsWidget::onManuallySetRealTimeClockChanged);
54+
SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.rtcUseSystemLocaleFormat, "EmuCore", "UseSystemLocaleFormat", false);
55+
connect(m_ui.rtcUseSystemLocaleFormat, &QCheckBox::checkStateChanged, this, &EmulationSettingsWidget::onUseSystemLocaleFormatChanged);
5456
EmulationSettingsWidget::onManuallySetRealTimeClockChanged();
57+
EmulationSettingsWidget::onUseSystemLocaleFormatChanged();
5558

5659
m_ui.eeCycleRate->insertItem(0,
5760
tr("Use Global Setting [%1]")
@@ -159,10 +162,12 @@ EmulationSettingsWidget::EmulationSettingsWidget(SettingsWindow* settings_dialog
159162
dialog()->registerWidgetHelp(m_ui.manuallySetRealTimeClock, tr("Manually Set Real-Time Clock"), tr("Unchecked"),
160163
tr("Manually set a real-time clock to use for the virtual PlayStation 2 instead of using your OS' system clock."));
161164
dialog()->registerWidgetHelp(m_ui.rtcDateTime, tr("Real-Time Clock"), tr("Current date and time"),
162-
tr("Real-time clock (RTC) used by the virtual PlayStation 2. Date format is the same as the one used by your OS. "
163-
"This time is only applied upon booting the PS2; changing it while in-game will have no effect. "
164-
"NOTE: This assumes you have your PS2 set to the default timezone of GMT+0 and default DST of Summer Time. "
165+
tr("Real-time clock (RTC) used by the virtual PlayStation 2.<br>"
166+
"This time is only applied upon booting the PS2; changing it while in-game will have no effect.<br>"
167+
"NOTE: This assumes you have your PS2 set to the default timezone of GMT+0 and default DST of Summer Time.<br>"
165168
"Some games require an RTC date/time set after their release date."));
169+
dialog()->registerWidgetHelp(m_ui.rtcUseSystemLocaleFormat, tr("Use System Locale Format"), tr("User Preference"),
170+
tr("Uses the operating system's date/time format rather than \"yyyy-mm-dd hh:mm:ss\". May exclude seconds."));
166171

167172
updateOptimalFramePacing();
168173
updateUseVSyncForTimingEnabled();
@@ -314,4 +319,11 @@ void EmulationSettingsWidget::onManuallySetRealTimeClockChanged()
314319
{
315320
const bool enabled = dialog()->getEffectiveBoolValue("EmuCore", "ManuallySetRealTimeClock", false);
316321
m_ui.rtcDateTime->setEnabled(enabled);
322+
m_ui.rtcUseSystemLocaleFormat->setEnabled(enabled);
323+
}
324+
325+
void EmulationSettingsWidget::onUseSystemLocaleFormatChanged()
326+
{
327+
const bool enabled = dialog()->getEffectiveBoolValue("EmuCore", "UseSystemLocaleFormat", false);
328+
m_ui.rtcDateTime->setDisplayFormat(enabled ? QLocale::system().dateTimeFormat(QLocale::ShortFormat) : "yyyy-MM-dd HH:mm:ss");
317329
}

pcsx2-qt/Settings/EmulationSettingsWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ private Q_SLOTS:
2424
void updateOptimalFramePacing();
2525
void updateUseVSyncForTimingEnabled();
2626
void onManuallySetRealTimeClockChanged();
27+
void onUseSystemLocaleFormatChanged();
2728

2829
Ui::EmulationSettingsWidget m_ui;
2930
};

pcsx2-qt/Settings/EmulationSettingsWidget.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@
266266
<item row="0" column="1">
267267
<widget class="QDateTimeEdit" name="rtcDateTime"/>
268268
</item>
269+
<item row="1" column="0">
270+
<widget class="QCheckBox" name="rtcUseSystemLocaleFormat">
271+
<property name="text">
272+
<string>Use System Locale Format</string>
273+
</property>
274+
</widget>
275+
</item>
269276
</layout>
270277
</widget>
271278
</item>

pcsx2/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,7 @@ struct Pcsx2Config
13151315
BackupSavestate : 1,
13161316
McdFolderAutoManage : 1,
13171317
ManuallySetRealTimeClock : 1,
1318+
UseSystemLocaleFormat : 1,
13181319

13191320
HostFs : 1,
13201321

pcsx2/Pcsx2Config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,7 @@ Pcsx2Config::Pcsx2Config()
19241924
WarnAboutUnsafeSettings = true;
19251925
EnableDiscordPresence = false;
19261926
ManuallySetRealTimeClock = false;
1927+
UseSystemLocaleFormat = false;
19271928

19281929
// To be moved to FileMemoryCard pluign (someday)
19291930
for (uint slot = 0; slot < 8; ++slot)
@@ -1973,6 +1974,7 @@ void Pcsx2Config::LoadSaveCore(SettingsWrapper& wrap)
19731974
SettingsWrapBitBool(WarnAboutUnsafeSettings);
19741975

19751976
SettingsWrapBitBool(ManuallySetRealTimeClock);
1977+
SettingsWrapBitBool(UseSystemLocaleFormat);
19761978

19771979
// Process various sub-components:
19781980

0 commit comments

Comments
 (0)