Skip to content

Commit c241dbc

Browse files
authored
tweak(gui): Use default locale of user for listed replays and save games to match regional date time formats (TheSuperHackers#2254)
1 parent 8e6360e commit c241dbc

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

  • GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame
  • Generals/Code/GameEngine/Source/Common/System/SaveGame

Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ GameState::SnapshotBlock *GameState::findBlockInfoByToken( AsciiString token, Sn
202202

203203
}
204204

205-
///////////////////////////////////////////////////////////////////////////////////////////////////
206-
///////////////////////////////////////////////////////////////////////////////////////////////////
207-
///////////////////////////////////////////////////////////////////////////////////////////////////
205+
// TheSuperHackers @tweak Use the user's default locale instead of the system default to match Windows regional settings.
206+
// This allows regional formats such as Europe (English) to use 24-hour and DD/MM/YYYY formats in-game.
208207
UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
209208
{
210209
// setup date buffer for local region date format
@@ -217,7 +216,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
217216
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
218217
{
219218
char dateBuffer[ DATE_BUFFER_SIZE ];
220-
GetDateFormat( LOCALE_SYSTEM_DEFAULT,
219+
GetDateFormat( LOCALE_USER_DEFAULT,
221220
DATE_SHORTDATE,
222221
&timeVal,
223222
nullptr,
@@ -227,7 +226,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
227226
}
228227
}
229228
wchar_t dateBuffer[ DATE_BUFFER_SIZE ];
230-
GetDateFormatW( LOCALE_SYSTEM_DEFAULT,
229+
GetDateFormatW( LOCALE_USER_DEFAULT,
231230
DATE_SHORTDATE,
232231
&timeVal,
233232
nullptr,
@@ -248,7 +247,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
248247
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
249248
{
250249
char timeBuffer[ DATE_BUFFER_SIZE ];
251-
GetTimeFormat( LOCALE_SYSTEM_DEFAULT,
250+
GetTimeFormat( LOCALE_USER_DEFAULT,
252251
TIME_NOSECONDS|TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER,
253252
&timeVal,
254253
nullptr,
@@ -260,7 +259,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
260259
// setup time buffer for local region time format
261260
#define TIME_BUFFER_SIZE 256
262261
wchar_t timeBuffer[ TIME_BUFFER_SIZE ];
263-
GetTimeFormatW( LOCALE_SYSTEM_DEFAULT,
262+
GetTimeFormatW( LOCALE_USER_DEFAULT,
264263
TIME_NOSECONDS,
265264
&timeVal,
266265
nullptr,

GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ GameState::SnapshotBlock *GameState::findBlockInfoByToken( AsciiString token, Sn
202202

203203
}
204204

205-
///////////////////////////////////////////////////////////////////////////////////////////////////
206-
///////////////////////////////////////////////////////////////////////////////////////////////////
207-
///////////////////////////////////////////////////////////////////////////////////////////////////
205+
// TheSuperHackers @tweak Use the user's default locale instead of the system default to match Windows regional settings.
206+
// This allows regional formats such as Europe (English) to use 24-hour and DD/MM/YYYY formats in-game.
208207
UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
209208
{
210209
// setup date buffer for local region date format
@@ -217,7 +216,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
217216
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
218217
{
219218
char dateBuffer[ DATE_BUFFER_SIZE ];
220-
GetDateFormat( LOCALE_SYSTEM_DEFAULT,
219+
GetDateFormat( LOCALE_USER_DEFAULT,
221220
DATE_SHORTDATE,
222221
&timeVal,
223222
nullptr,
@@ -227,7 +226,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
227226
}
228227
}
229228
wchar_t dateBuffer[ DATE_BUFFER_SIZE ];
230-
GetDateFormatW( LOCALE_SYSTEM_DEFAULT,
229+
GetDateFormatW( LOCALE_USER_DEFAULT,
231230
DATE_SHORTDATE,
232231
&timeVal,
233232
nullptr,
@@ -248,7 +247,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
248247
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
249248
{
250249
char timeBuffer[ DATE_BUFFER_SIZE ];
251-
GetTimeFormat( LOCALE_SYSTEM_DEFAULT,
250+
GetTimeFormat( LOCALE_USER_DEFAULT,
252251
TIME_NOSECONDS|TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER,
253252
&timeVal,
254253
nullptr,
@@ -260,7 +259,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
260259
// setup time buffer for local region time format
261260
#define TIME_BUFFER_SIZE 256
262261
wchar_t timeBuffer[ TIME_BUFFER_SIZE ];
263-
GetTimeFormatW( LOCALE_SYSTEM_DEFAULT,
262+
GetTimeFormatW( LOCALE_USER_DEFAULT,
264263
TIME_NOSECONDS,
265264
&timeVal,
266265
nullptr,

0 commit comments

Comments
 (0)