After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 163842 - Use nl_langinfo when it's available to determine first day of the week
Use nl_langinfo when it's available to determine first day of the week
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
unspecified
Other Linux
: Normal normal
: Small feature
Assigned To: gtk-bugs
gtk-bugs
: 308112 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-01-12 18:56 UTC by Vincent Untz
Modified: 2005-06-18 04:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (2.31 KB, patch)
2005-01-12 18:58 UTC, Vincent Untz
needs-work Details | Review
Patch with additional test (2.35 KB, patch)
2005-01-13 14:03 UTC, Vincent Untz
none Details | Review
Correctly detect if _NL_TIME_FIRST_WEEKDAY is available (1.84 KB, patch)
2005-01-13 21:38 UTC, Vincent Untz
none Details | Review

Description Vincent Untz 2005-01-12 18:56:11 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.
Comment 1 Vincent Untz 2005-01-12 18:58:32 UTC
Created attachment 35904 [details] [review]
Patch
Comment 2 Matthias Clasen 2005-01-13 13:00:03 UTC
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.
Comment 3 Vincent Untz 2005-01-13 13:48:03 UTC
What about doing this:

#if defined (HAVE_NL_LANGINFO) && defined (_NL_TIME_FIRST_WEEKDAY)
    week_start = nl_langinfo (_NL_TIME_FIRST_WEEKDAY);
    ...
#else
    ...
#endif
Comment 4 Matthias Clasen 2005-01-13 13:49:20 UTC
Sounds good
Comment 5 Vincent Untz 2005-01-13 14:03:06 UTC
Created attachment 35954 [details] [review]
Patch with additional test
Comment 6 Matthias Clasen 2005-01-13 19:38:33 UTC
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)

Comment 7 Tommi Komulainen 2005-01-13 20:09:27 UTC
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.
Comment 8 Vincent Untz 2005-01-13 21:37:47 UTC
Tommi is right: there's no define for _NL_TIME_FIRST_WEEKDAY. Shame on me.
I'm attaching a patch.
Comment 9 Vincent Untz 2005-01-13 21:38:22 UTC
Created attachment 35976 [details] [review]
Correctly detect if _NL_TIME_FIRST_WEEKDAY is available
Comment 10 Matthias Clasen 2005-01-14 13:44:45 UTC
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.

Comment 11 Owen Taylor 2005-06-17 18:53:25 UTC
*** Bug 308112 has been marked as a duplicate of this bug. ***
Comment 12 Pierre Ossman 2005-06-17 20:29:18 UTC
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? :))
Comment 13 Matthias Clasen 2005-06-17 20:47:15 UTC
Please reopen bugs when adding comments
Comment 14 Matthias Clasen 2005-06-18 04:19:41 UTC
2005-06-18  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkcalendar.c (gtk_calendar_init): _NL_FIRST_WEEKDAY is
        1-based.  (#163842, Pierre Ossman)