At this point, the remaining test failures of the nstrftime, c-nstrftime tests on native Windows are:
NZST-12NZDT,M9.5.0,M4.1.0/3: expected "1970-01-01 13:00:00 +1300 (NZDT)", got "1970-01-01 01:00:00 (W. Europe Standard Time)" NZST-12NZDT,M9.5.0,M4.1.0/3: expected "1985-11-05 13:53:21 +1300 (NZDT)", got "1985-11-05 01:53:21 +0100 (W. Europe Standard Time)" NZST-12NZDT,M9.5.0,M4.1.0/3: expected "2001-09-09 13:46:42 +1200 (NZST)", got "2001-09-09 03:46:42 +0200 (W. Europe Daylight Time)" The Windows documentation of the time zone names <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset> makes it clear that only 3 letters are accepted, not 4, in the main time zone name. In order to have at least 2 out of the 3 failures disappear, it is useful to define the GMT offset of this time zone as -13 rather than -12. Then, only one test has to be disabled. With this patch, the nstrftime, c-nstrftime tests now pass on mingw and MSVC. 2024-05-27 Bruno Haible <br...@clisp.org> nstrftime, c-nstrftime tests: Avoid test failures on native Windows. * doc/posix-functions/tzset.texi: Add a reference. * tests/test-nstrftime.h (TZ): Use time zone names that are supported by native Windows. (LT): Disable a test of New Zealand DST. diff --git a/doc/posix-functions/tzset.texi b/doc/posix-functions/tzset.texi index 983789eca7..30901d3488 100644 --- a/doc/posix-functions/tzset.texi +++ b/doc/posix-functions/tzset.texi @@ -16,6 +16,7 @@ Portability problems not fixed by Gnulib: @itemize @item +@c https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset Native Windows platforms (mingw, MSVC) support only a subset of POSIX-specified values for the @env{TZ} environment variable, consisting of a time zone abbreviation containing exactly three ASCII diff --git a/tests/test-nstrftime.h b/tests/test-nstrftime.h index d8e2a3915d..50c270440d 100644 --- a/tests/test-nstrftime.h +++ b/tests/test-nstrftime.h @@ -103,18 +103,29 @@ static struct tzalloc_test TZ[] = { #define Pacific 0 { 0, "PST8PDT,M3.2.0,M11.1.0" }, + #define Arizona 1 { 0, "MST7" }, + #define UTC 2 { 0, 0 }, + #define CentEur 3 { 0, "CET-1CEST,M3.5.0,M10.5.0/3" }, + #define Japan 4 { 0, "JST-9" }, + #define NZ 5 +#if defined _WIN32 && !defined __CYGWIN__ + { 0, "NST-13NDT" }, +#else { 0, "NZST-12NZDT,M9.5.0,M4.1.0/3" }, +#endif + #define Unknown 6 { 0, "<-00>0" }, + { 0 } }; @@ -157,7 +168,9 @@ static struct localtime_rz_test LT[] = { TZ+UTC , 1000000002, "2001-09-09 01:46:42 +0000 (UTC)", 0 }, { TZ+CentEur, 1000000002, "2001-09-09 03:46:42 +0200 (CEST)", 0 }, { TZ+Japan , 1000000002, "2001-09-09 10:46:42 +0900 (JST)", 0 }, +#if !(defined _WIN32 && !defined __CYGWIN__) { TZ+NZ , 1000000002, "2001-09-09 13:46:42 +1200 (NZST)", 0 }, +#endif #if TZ_ANGLE_BRACKETS_SHOULD_WORK && !defined __FreeBSD__ { TZ+Unknown, 0, "1970-01-01 00:00:00 -0000 (-00)", 0 }, { TZ+Unknown, 500000001, "1985-11-05 00:53:21 -0000 (-00)", 0 },