Hi, Graham Wilson, le Fri 07 Apr 2006 16:26:44 -0500, a écrit : > On Fri, Apr 07, 2006 at 11:42:10AM +0200, Samuel Thibault wrote: > > Samuel Thibault, le Fri 07 Apr 2006 11:28:31 +0200, a ?crit : > > > cal currently has -s and -m options for choosing the first day of the > > > week. This shouldn't be necessary, thanks to locales > > > (langinfo(_NL_TIME_FIRST_WEEKDAY)). > > > > Actually, more generally cal should use _NL_TIME_WEEK_NDAYS, > > _NL_TIME_WEEK_1STDAY, _NL_TIME_WEEK_1STWEEK, _NL_TIME_FIRST_WEEKDAY, and > > ABDAY_1, ABDAY_2, etc. for properly printing a fully localized calendar. > > The next upload of bsdmainutils will support using > _NL_TIME_FIRST_WEEKDAY (see #288472), now that glibc properly supports > this.
Great! > I've not, however, integrated support for any of the other constants. > cal currently uses strftime to format names according to the current > locale when it needs to. Is there a reason to use langinfo(3) for this > instead? Ah, ok. (I was indeed wondering where the weekdays were coming from). Well, stricly speaking, _NL_TIME_FIRST_WEEKDAY doesn't return an absolute day number, but a day number relatively to the day of _NL_TIME_WEEK_1STDAY: for instance, with a en_US locale, (int) nl_langinfo(_NL_TIME_WEEK_1STDAY) returns 19971130 as "first day of week system", which is a Sunday. And * nl_langinfo(_NL_TIME_FIRST_WEEKDAY) returns 1, which means "the first day of the week system", hence Sunday. With a fr_FR locale, (int) nl_langinfo(_NL_TIME_WEEK_1STDAY) returns 19971130 too (hence the first day of the week system is a Sunday too) and * nl_langinfo(_NL_TIME_FIRST_WEEKDAY) returns 2, which means 'the second day of the week system', hence Monday. Why such complexity? Because there may be other week systems, and there are: ISO/IEC 14652 sets _NL_TIME_WEEK_1STDAY to 19971201, which is a monday, and hence if in some locale * nl_langinfo(_NL_TIME_FIRST_WEEKDAY) returns 1, that means a monday (since the first day of the week system is 19971201, a monday). Plus there may be week systems where the number of days is not 7, so * nl_langinfo(_NL_TIME_WEEK_NDAYS) should be used for getting the number of days in a week, and then compute and display week days accordingly. Finally, there is * nl_langinfo(_NL_TIME_CAL_DIRECTION) that returns the direction of the days in a calendar: 1 : left-right from top 2 : top-down from left 3 : right-left from top Regards, Samuel -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]