I wrote: > While the three new unit tests succeed on mingw, they fail on MSVC.
Testing with a newer mingw and a newer UCRT, I again see the tests fail: FAIL: test-localtime-w32 ======================== Windows API 1: 2026-09-12 08:00:00 Windows API 2: 2026-09-12 08:00:00 localtime: 2026-09-12 09:00:00 (DST=1) ../../gltests/test-localtime-w32.c:115: assertion 'lm->tm_hour == lsystime1.wHour' failed FAIL test-localtime-w32.exe (exit status: 1) FAIL: test-mktime-w32 ===================== Windows API 1: 1789200000 Windows API 2: 1789200000 mktime: 1789196400 timegm: 1789200000 ../../gltests/test-mktime-w32.c:130: assertion 'utctime == utctime1' failed FAIL test-mktime-w32.exe (exit status: 1) FAIL: test-localtime_r-w32 ========================== Windows API 1: 2026-09-12 08:00:00 Windows API 2: 2026-09-12 08:00:00 localtime_r: 2026-09-12 09:00:00 (DST=1) ../../gltests/test-localtime_r-w32.c:113: assertion 'lm.tm_hour == lsystime1.wHour' failed FAIL test-localtime_r-w32.exe (exit status: 1) This patch fixes it. 2026-10-06 Bruno Haible <[email protected]> tzsanitize: Make it work on recent versions of mingw+UCRT. * lib/tzsanitize.c (tzsanitize): Call SetEnvironmentVariable also on mingw+UCRT. diff --git a/lib/tzsanitize.c b/lib/tzsanitize.c index dd4f31173f..1963dfbeb4 100644 --- a/lib/tzsanitize.c +++ b/lib/tzsanitize.c @@ -25,7 +25,7 @@ #include <string.h> #include <wchar.h> -#if !defined __MINGW32__ +#if !defined __MINGW32__ || defined _UCRT # define WIN32_LEAN_AND_MEAN /* avoid including junk */ # include <windows.h> #endif @@ -56,11 +56,11 @@ tzsanitize (void) if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') ws[0] = L'$'; } -#if !defined __MINGW32__ +#if !defined __MINGW32__ || defined _UCRT SetEnvironmentVariable ("TZ", NULL); #endif } -#if !defined __MINGW32__ +#if !defined __MINGW32__ || defined _UCRT /* On MSVC, we also need to sanitize the environment variables stored in the process's environment block. We don't lose much by assuming that the environment variable's value
