]> Savannah Git Hosting - gnulib.git/commitdiff
nstrftime: Make %r work on macOS, FreeBSD, native Windows.
authorBruno Haible <bruno@clisp.org>
Mon, 27 May 2024 21:29:36 +0000 (23:29 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 31 May 2024 22:06:11 +0000 (00:06 +0200)
* doc/posix-functions/strftime.texi: Mention the %r problem.
* lib/nstrftime.c (__strftime_internal): On macOS, FreeBSD, and native
Windows, for %r, use the English AM/PM format.

ChangeLog
doc/posix-functions/strftime.texi
lib/nstrftime.c

index bc9c4e8901e5b940d39ee975a6342818f0b6a0db..21144a3dff9f25d001def52b62f7a79976048981 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-05-27  Bruno Haible  <bruno@clisp.org>
+
+       nstrftime: Make %r work on macOS, FreeBSD, native Windows.
+       * doc/posix-functions/strftime.texi: Mention the %r problem.
+       * lib/nstrftime.c (__strftime_internal): On macOS, FreeBSD, and native
+       Windows, for %r, use the English AM/PM format.
+
 2024-05-27  Bruno Haible  <bruno@clisp.org>
 
        nstrftime: Make %h work on native Windows.
index b0bd2b536ee832e97dd5593b41fe28e8fa6975e2..1455fcdc9c861688e563e737ea701f3b30dee65c 100644 (file)
@@ -23,6 +23,9 @@ mingw, MSVC.
 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 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).
index ed9118ab1cfe8fb0fb73b5503b0cc3256fee62df..bb0ac99cb2b95ae124dafb9fae18376590b7c422 100644 (file)
@@ -1181,6 +1181,11 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
               == L_('\0'))
             subfmt = L_("%I:%M:%S %p");
           goto subformat;
+#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
           goto underlying_strftime;
 #endif