This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]