On mingw, I see that the %r specifier testing code runs into the assertion of ASSERT (n > 0).
This patch adds support for the %r specifier. 2024-05-27 Bruno Haible <br...@clisp.org> nstrftime, c-nstrftime: Make %r work on native Windows. * doc/posix-functions/strftime.texi: Mention the %r problem. * lib/strftime.c (__strftime_internal): On native Windows, for %r, use the English AM/PM format. diff --git a/doc/posix-functions/strftime.texi b/doc/posix-functions/strftime.texi index 7cba218a97..3a2eceb8ef 100644 --- a/doc/posix-functions/strftime.texi +++ b/doc/posix-functions/strftime.texi @@ -28,6 +28,9 @@ The %h specifier produces empty output on some platforms: mingw, MSVC. @item +The %r specifier produces empty 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. diff --git a/lib/strftime.c b/lib/strftime.c index ccfa79daac..8eeea45ef4 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1717,8 +1717,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #elif USE_C_LOCALE && !HAVE_STRFTIME_L subfmt = L_("%I:%M:%S %p"); goto subformat; -#elif (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ - /* macOS, FreeBSD strftime() may produce empty output for "%r". */ +#elif (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || (defined _WIN32 && !defined __CYGWIN__) + /* macOS, FreeBSD, native Windows strftime() may produce empty output + for "%r". */ subfmt = L_("%I:%M:%S %p"); goto subformat; #else