This is the mail archive of the libc-locales@sourceware.org mailing list for the GNU libc locales 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]

LC_TIME first_weekday locale consolidation


Hi!

I have sent this off half a year ago in the hopes of generating some
discussion, however there was none in the end - maybe if I resend it to
the libc-locale mailing list, I will have better chances. :-) You are
welcome to discuss whether my understanding of the specs is correct and
how to implement it best.

In the  meantime, I have grown less sure about my recommendation to use
week[2] (week_1stday) to semantically specify the first day of week.
Maybe it would be te purer solution, but it has been for long documented
that DAY_1 in nl_langinfo() is always Sunday and many applicaitons might
rely on it; thus, it would be probably safer to keep this convention in
order to not confuse applications that are not aware of first_weekday
and week[2] (week_1stday). I.e. always have days[] Sunday-based (like
now) and only adjust first_weekday to specify the correct first day of
the week (in the most of the world, the value would be 2).

Regardless, you can now easily verify if your locale has correct (as in
my understanding of the specs) first_weekday information by using a
testapp at http://pasky.or.cz/~pasky/dev/glibc/first_weekday.c - the two
names printed should match (and be correct). See also
http://sourceware.org/bugzilla/show_bug.cgi?id=7068 for what triggered
this repost. ;-)

----- Forwarded message from Petr Baudis <pasky@suse.cz> -----

From: Petr Baudis <pasky@suse.cz>
To: libc-alpha@sourceware.org
Subject: LC_TIME first_weekday locale consolidation
Date: Mon, 9 Jun 2008 20:21:32 +0200

  Hi,

  it seems that the interaction between first_weekday, week and day
LC_TIME keywords is mostly poorly understood among locale authors and
some obviously bogus patches have been checked in over the years.


  First, to clear things up a bit, ISO 14652 specifies the keywords to
work like this:

  * day list starts with the day of week derived from the week keyword
specification, either Sunday or Monday (as opposed to original POSIX
spec, which just says the list starts with Sunday).

  * week is followed by a list of three values: The number of days in a
week (by default 7), a date of beginning of the week (by default
corresponds to Sunday), and the minimal length of the first week in year
(by default 4). Regarding the start of the week, 19971130 shall be
used for Sunday and 19971201 shall be used for Monday. Thus,
countries using 19971130 should have local Sunday name as the first day
in the day list, while countries using 19971201 should have Monday
translation as the first item in teh day list.

  * first_weekday is (1-based) index of the first day from the day list
to be shown in calendar applications. The default value of 1 corresponds
to either Sunday or Monday depending on the value of the second week
list item.

  (I have submitted this description as a patch for locale(5) already.)


  As for the confusion, compare two commits - ru_RU change from Feb 17
07:26:33 2007 and several locales (e.g. en_GB) from Sep 30 18:31:47
2007.

  In ru_RU, week_1stday is 19971130 (Sunday), first_weekday is set to 2
(Monday) and day translations are starting with Sunday, which is
technically correct (but see below).

  However, in en_GB, week_1stday is 19971201 (Monday), first_weekday is
set to 1 (Monday), however day translations are _still_ starting with
Sunday! Thus, a calendar application would display the correct tabular
view but wrong weekday labels.

  Am I understanding the specs right? Regardless, one of the changes
was certainly wrong and we should restore the consistency here and
clearly specify how applications should handle the fields.


  Unfortunately, due to the baroque ISO 14652 mess, there are two
alternate ways to specify week starts - either week[2] value of
first_weekday. My understanding of the specs seems to be that
first_weekday has only presentation purpose, while week[2] has the
semantic meaning.

  IOW, week[2] answers "Would you say Sunday is day of week #0 or #7?"
while first_weekday gives the n for "What day of week #n should be shown
in the first column of calendar listing." (It is rather curious to me
that there is no strftime() spec that would work like either %u or %w
based on first_weekday. Maybe that is how %Of is supposed to work like?
I have no idea what 'alt_day' is.)

  I believe that in almost all cases, you want to specify Monday-based
locale by answering the first question - thus, using week[2] instead of
first_weekday. Do you agree with this implementation? In that case,
something along these lines should be added to localedata/README or some
other file to provide a guideline for the locale data creators.


  Regarding the current situation, the easiest fix is probably to check
Bugzilla and go through all the locales where weeks are supposed to
start with Monday, and resolve the obvious week+first_weekday <-> day
inconsistencies by rotating the day list, putting Sunday to the end.
If people agree this is the right solution, I can do this, as well
as documenting the relevant _NL_TIME_* attributes (since application
programmers seem to be confused about this too).


  Auxiliary reading:

  http://gentoo-wiki.com/HOWTO_localedef#LC_TIME_settings
  http://std.dkuug.dk/JTC1/SC22/WG20/docs/n897-14652w25.pdf
  http://sourceware.org/bugzilla/show_bug.cgi?id=2388


  Kind regards,

-- 
				Petr "Pasky" Baudis
Whatever you can do, or dream you can, begin it.
Boldness has genius, power, and magic in it.	-- J. W. von Goethe

----- End forwarded message -----

-- 
				Petr "Pasky" Baudis
The average, healthy, well-adjusted adult gets up at seven-thirty
in the morning feeling just terrible. -- Jean Kerr


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