Incorrect first_weekday for POSIX locale
Petter Reinholdtsen
pere@hungry.com
Tue May 18 21:57:00 GMT 2004
I recently discovered something strange about the first_weekday in the
POSIX locale. If I understand this value correctly, it should have
values 1 to 7, where 1 is Sunday, 2 is Monday and 7 is Saturady. It
is never 0.
And further, the POSIX locale should have first weekday on sunday, and
thus return 1 in this code. It doesn't:
#include <stdio.h>
#include <locale.h>
#include <langinfo.h>
int main() {
int first_weekday;
setlocale(LC_TIME, "POSIX");
first_weekday = *nl_langinfo(_NL_TIME_FIRST_WEEKDAY);
printf("first_weekday for POSIX locale = %d\n", first_weekday);
return 0;
}
The output from the program is surprisingly:
first_weekday for POSIX locale = 7
The nb_NO locales with no first_weekday value return 1. Is the POSIX
locale broken, or am I mistaken? The first_weekday is not in the
POSIX spec, so I am not sure where to check how this is supposed to
work.
More information about the Libc-alpha
mailing list