Bug#327025: C locale has bad default for _NL_TIME_FIRST_WEEKDAY
Package: locales
Version: 2.3.5-6
Severity: normal
The _NL_TIME_FIRST_WEEKDAY symbol, when passed to nl_langinfo, is
supposed to give the first day of the week. This seems to work
correctly for most locales. However, the results for the POSIX locale
seem odd. I think it would make more sense for POSIX to default to
Sunday as the first day of the week, rather than Saturday.
$ gcc -o test test.c
$ ./test
POSIX: Saturday
en_US: Sunday
en_GB: Sunday
es_ES: Sunday
nl_NL: Sunday
fi_FI: Monday
I've attached the sample code that generates the above.
--
gram
#include <langinfo.h>
#include <locale.h>
#include <stdio.h>
#include <time.h>
void
foo(const char *s)
{
struct tm tm;
char buf[16];
setlocale(LC_ALL, s);
tm.tm_wday = *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1;
setlocale(LC_ALL, "C");
strftime(buf, sizeof(buf), "%A", &tm);
printf("%s: %s\n", s, buf);
}
int
main(int argc, char *argv[])
{
foo("POSIX");
foo("en_US");
foo("en_GB");
foo("es_ES");
foo("nl_NL");
foo("fi_FI");
return 0;
}
Reply to: