Hi Sean,

Sean McBride wrote on Wed, Nov 15, 2023 at 08:36:25PM -0500:

> I tried building the fmt library on OpenBSD 7.4 on x86_64 and a few of 
> its unit tests fail.  First we thought it was maybe a libc++ bug, but in 
> fact it seems to be an OpenBSD bug:
> 
> Reduced case:
> 
> ```c
> #include <stdio.h>
> #include <locale.h>
> #include <time.h>
> #include <wchar.h>
> 
> int main() {
>    setlocale(LC_TIME, "es_ES.UTF-8");
>    wchar_t str[100];
>    time_t t = time(NULL);
>    wcsftime(str, 100, L"%a", localtime(&t));
>    wprintf(L"%ls\n", str);
> }
> ```
> 
> When run on a Tuesday, it gives "Tue". It should be outputting "mar", 
> for Spanish "martes" (meaning Tuesday). That's what I get with macOS and 
> FreeBSD.

That's not a bug but a feature.

We intentionally do not support LC_* variables other than LC_CTYPE
because reliability and predictability are much more important.
This functionality is totally misplaced in libc and should never
have been added to POSIX.

For details, see the locale(1), setlocale(3), wcsftime(3), and strftime(3)
manual pages.

Yours,
  Ingo

Reply via email to