* doc/posix-functions/strftime.texi: Mention the %c problem.
* lib/strftime.c: Include <locale.h> always. 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, c-nstrftime: Make %c work on native Windows.
+ * doc/posix-functions/strftime.texi: Mention the %c problem.
+ * lib/strftime.c: Include <locale.h> always. 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.
on some platforms:
glibc 2.30, NetBSD 10.0, Solaris 11.4.
@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 %r specifier produces empty output, at least in a French locale,
on some platforms:
macOS 12.5, FreeBSD 14.0.
#include <stdlib.h>
#include <string.h>
-#if USE_C_LOCALE && HAVE_STRFTIME_L
-# include <locale.h>
-#endif
-
+#include <locale.h>
#if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM
-# include <locale.h>
# include "localename.h"
#endif
+#if !USE_C_LOCALE
+# include "hard-locale.h"
+#endif
#include "attribute.h"
#include <intprops.h>
subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT));
#elif USE_C_LOCALE && !HAVE_STRFTIME_L
subfmt = L_("%a %b %e %H:%M:%S %Y");
+#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
localename-unsafe-limited
stdbool
Include:
"strftime.h"
+Link:
+$(HARD_LOCALE_LIB)
+
License:
LGPL
LOCALE_FR='@LOCALE_FR@' \
LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
check_PROGRAMS += test-nstrftime
-test_nstrftime_LDADD = $(LDADD) $(SETLOCALE_LIB)
+test_nstrftime_LDADD = $(LDADD) $(SETLOCALE_LIB) $(HARD_LOCALE_LIB)