* doc/posix-functions/strftime.texi: Mention the %c problem.
* lib/nstrftime.c: Include <locale.h>. Include hard-locale.h.
(__strftime_internal): For %c, use a subformat that contains the weekday
name (or abbrev.) and the month name (or abbrev.).
* modules/nstrftime (Depends-on): Add hard-locale.
(Link): New section.
* modules/nstrftime-tests (Makefile.am): Link test-nstrftime with
$(HARD_LOCALE_LIB).
+2024-05-27 Bruno Haible <bruno@clisp.org>
+
+ nstrftime: Make %c work on native Windows.
+ * doc/posix-functions/strftime.texi: Mention the %c problem.
+ * lib/nstrftime.c: Include <locale.h>. Include hard-locale.h.
+ (__strftime_internal): For %c, use a subformat that contains the weekday
+ name (or abbrev.) and the month name (or abbrev.).
+ * modules/nstrftime (Depends-on): Add hard-locale.
+ (Link): New section.
+ * modules/nstrftime-tests (Makefile.am): Link test-nstrftime with
+ $(HARD_LOCALE_LIB).
+
2024-05-27 Bruno Haible <bruno@clisp.org>
tests: Fix internationalization problems on native Windows.
Portability problems not fixed by Gnulib:
@itemize
@item
+The %c specifier produces no weekday name and no month name, only a
+potentially ambiguous numerical output, on some platforms:
+mingw, MSVC.
+@item
The Windows C runtime library (which is used by MinGW) does not
support the %e specifier (and possibly the other more recent SUS
specifiers too, i.e., %C, %D, %h, %n, %r, %R, %t, and %T).
#include <stdlib.h>
#include <string.h>
+#include <locale.h>
+#include "hard-locale.h"
+
#include "attribute.h"
#include <intprops.h>
NLW(ERA_D_T_FMT)))
!= '\0')))
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
+#elif defined _WIN32 && !defined __CYGWIN__
+ /* On native Windows, "%c" is "%d/%m/%Y %H:%M:%S" by default. */
+ if (hard_locale (LC_TIME))
+ subfmt = L_("%a %e %b %Y %H:%M:%S");
+ else
+ subfmt = L_("%a %b %e %H:%M:%S %Y");
#else
goto underlying_strftime;
#endif
errno
extensions
intprops
+hard-locale
libc-config
stdbool
stdckdint
Include:
"strftime.h"
+Link:
+$(HARD_LOCALE_LIB)
+
License:
LGPL
Makefile.am:
TESTS += test-nstrftime
check_PROGRAMS += test-nstrftime
+test_nstrftime_LDADD = $(LDADD) $(HARD_LOCALE_LIB)