Skip to content

Commit 0613950

Browse files
Enforce std::time_base::mdy for "C" locale (#4437)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent 1fa7781 commit 0613950

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stl/src/xdateord.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
_EXTERN_C_UNLESS_PURE
1111

1212
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Getdateorder() noexcept { // return date order for current locale
13+
const wchar_t* const locale_name = ___lc_locale_name_func()[LC_TIME];
14+
if (locale_name == nullptr) { // Indicates "C" locale; GetLocaleInfoEx would see this as LOCALE_NAME_USER_DEFAULT
15+
return std::time_base::mdy;
16+
}
17+
1318
wchar_t buf[2] = {0};
14-
GetLocaleInfoEx(___lc_locale_name_func()[LC_TIME], LOCALE_ILDATE, buf, static_cast<int>(std::size(buf)));
19+
GetLocaleInfoEx(locale_name, LOCALE_ILDATE, buf, static_cast<int>(std::size(buf)));
1520

1621
switch (buf[0]) {
1722
case L'0':

0 commit comments

Comments
 (0)