This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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,

  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


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