This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Incorrect first_weekday for POSIX locale
- From: Petter Reinholdtsen <pere at hungry dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Tue, 18 May 2004 23:56:59 +0200
- Subject: Incorrect first_weekday for POSIX locale
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.