Hi Bruno, Collin Funk <collin.fu...@gmail.com> writes:
> The issue is that they return the non-C locale date. The code we use > when --iso-8601 or --rfc-3339 is in use is the following: > > if (use_c_locale) > setlocale (LC_TIME, "C"); > > bool ok = show_date (format, when, tz); > > I wonder if the issue is the cached_localename in > gl_locale_name_posix_unsafe of Gnulib's lib/localename-unsafe.c. Maybe > it causes strftime to read the old locale when setlocale (LC_TIME, "C") > was called. > > Hopefully I can debug this on the cfarm machine. Seems like I was onto something here. Unfortunately, it seems that you need some special permissions on MacOS to use lldb, so I cannot use it on cfarm104. However, I think some printf debugging will work fine to demonstrate. I created a Coreutils tarball with the following Gnulib patch: diff --git a/lib/strftime.c b/lib/strftime.c index 6495a6847e..750b4ccd8a 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -111,6 +111,7 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> +#include <stdio.h> #if (defined __NetBSD__ || defined __sun) && REQUIRE_GNUISH_STRFTIME_AM_PM # include "localename.h" @@ -1118,6 +1119,7 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) if (strcmp (locale_charset (), "UTF-8") == 0) { const char *loc = gl_locale_name_unsafe (LC_TIME, "LC_TIME"); + printf ("%s\n", loc); if (strlen (loc) >= 5 && !(loc[5] >= 'A' && loc[5] <= 'Z')) { if (memcmp (loc, "th_TH", 5) == 0) Here is two example runs on GNU/Linux to demonstrate the correct behavior: $ LC_ALL=am_ET.UTF-8 ./src/date am_ET.UTF-8 ሰኞ፣ ሐምሌ 21 ቀን 7:12:26 ከሰዓት PDT 2017 ዓ/ም $ LC_ALL=am_ET.UTF-8 ./src/date --iso-8601 C 2025-07-28 Then on MacOS 12.6 (cfarm104) which is the incorrect behavior: $ LC_ALL=am_ET.UTF-8 ./src/date am_ET.UTF-8 ሰኞ ሐም 21 21:14:24 CDT 2017 $ LC_ALL=am_ET.UTF-8 ./src/date --iso-8601 am_ET.UTF-8 2017-11-21 It looks like the issue here is that Apple's CoreFoundation locale functionality only cares about LC_ALL. Since changing the code I sent my previous message to: if (use_c_locale) setlocale (LC_ALL, "C"); bool ok = show_date (format, when, tz); Will emit: $ LC_ALL=am_ET.UTF-8 ./src/date --iso-8601 2025-07-28 But doing that seems unfortunate since error messages from show_date will now be printed in English, when that is not wanted... Collin