On Wed, 19 Nov 2025, Pali Rohár wrote:
Thanks for input. I started writing new TZ=PST8PDT tests and I they are failing, seems like some another issue with _localtime64. I started debugging it and I figured out that the my test is failing even with the native CRT 32-bit locatime version on Windows XP.Here is the test: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <assert.h> #ifdef __GLIBC__ typedef long int __time32_t; struct tm *_localtime32(const __time32_t *timep) { return localtime(&(time_t){*timep}); } __time32_t _mktime32(struct tm *tm) { return mktime(tm); } #endif int main() { __time32_t t32, t32_; struct tm *htm; struct tm tm2; putenv ("TZ=PST8PDT"); tzset (); t32 = 1130661000; /* Sun Oct 30 08:30:00 UTC 2005 == Sun Oct 30 01:30:00 PDT 2005 */ htm = _localtime32 (&t32); tm2 = *htm; printf ("pacific _localtime32(%ld): sec=%d min=%d hour=%d mday=%d mon=%d year=%d wday=%d yday=%d isdst=%d\n", t32, htm->tm_sec, htm->tm_min, htm->tm_hour, htm->tm_mday, htm->tm_mon, htm->tm_year, htm->tm_wday, htm->tm_yday, htm->tm_isdst); t32_ = _mktime32 (htm); printf ("pacific _mktime32(): %ld sec=%d min=%d hour=%d mday=%d mon=%d year=%d wday=%d yday=%d isdst=%d\n", t32_, htm->tm_sec, htm->tm_min, htm->tm_hour, htm->tm_mday, htm->tm_mon, htm->tm_year, htm->tm_wday, htm->tm_yday, htm->tm_isdst); fflush (stdout); assert (t32_ == t32); assert (memcmp (htm, &tm2, sizeof(tm2)) == 0); return 0; } On Windows XP when compiled with system os msvcrt.dll library it is failing with error: pacific _localtime32(1130661000): sec=0 min=30 hour=1 mday=30 mon=9 year=105 wday=0 yday=302 isdst=1 pacific _mktime32(): 1130664600 sec=0 min=30 hour=1 mday=30 mon=9 year=105 wday=0 yday=302 isdst=0 Assertion failed: t32_ == t32, file test.c, line 30
Hmm, so it seems like _localtime32 does the right thing, but _mktime32 fails to handle the daylight saving time aspect.
Do you have any idea what is wrong here? Bug in the msvcrt.dll or I have missed something in the test?
I tested this on a Windows 11 machine, and there it does produce the right result, so something seems to have changed in msvcrt.dll (or other system components relating to this) between XP and 11.
// Martin _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
