GNOME Bugzilla – Bug 163842
Use nl_langinfo when it's available to determine first day of the week
Last modified: 2005-06-18 04:19:41 UTC
I got tired of marking bugs as duplicate of bug #87977, so I did what Matthias suggested in http://bugzilla.gnome.org/show_bug.cgi?id=87977#c25. Patch will follow.
Created attachment 35904 [details] [review] Patch
Comment on attachment 35904 [details] [review] Patch Is it guaranteed that _NL_TIME_FIRST_WEEKDAY will be defined if we find nl_langinfo ? I think not, since that belongs to the non-standard glibc extensions to no_langinfo. Probably better to add a configure check for it too.
What about doing this: #if defined (HAVE_NL_LANGINFO) && defined (_NL_TIME_FIRST_WEEKDAY) week_start = nl_langinfo (_NL_TIME_FIRST_WEEKDAY); ... #else ... #endif
Sounds good
Created attachment 35954 [details] [review] Patch with additional test
2005-01-13 Matthias Clasen <mclasen@redhat.com> * configure.in: Check for nl_langinfo() * gtk/gtkcalendar.c: (gtk_calendar_init): Use nl_langinfo() when it's available to determine first day of week (#163842, Vincent Untz)
I don't believe it's guaranteed that _NL_TIME_FIRST_WEEKDAY is a #define. At least on RH9 (glibc 2.3.2) it happens to be an enum and using #if defined() doesn't work as one would expect. The check needs to be done in configure.in, I think. There's one in Galeon if you need an example.
Tommi is right: there's no define for _NL_TIME_FIRST_WEEKDAY. Shame on me. I'm attaching a patch.
Created attachment 35976 [details] [review] Correctly detect if _NL_TIME_FIRST_WEEKDAY is available
2005-01-14 Matthias Clasen <mclasen@redhat.com> * configure.in: Check for _NL_TIME_FIRST_WEEKDAY too, since it is an enum value, not a define. Pointed out by Tommi Komulainen. * gtk/gtkcalendar.c (gtk_calendar_init): Adapt.
*** Bug 308112 has been marked as a duplicate of this bug. ***
The patch is buggy though. _NL_TIME_FIRST_WEEKDAY is 1-based while the code expects a 0-based value. E.g. sv_SE reports 2 as the first day of the week which is supposed to mean monday. But with this patch tuesday becomes the first day. (Also, could this be back-ported to the 2.6.x branch? Pretty please? :))
Please reopen bugs when adding comments
2005-06-18 Matthias Clasen <mclasen@redhat.com> * gtk/gtkcalendar.c (gtk_calendar_init): _NL_FIRST_WEEKDAY is 1-based. (#163842, Pierre Ossman)