Re: [util-linux] cal doesn't honor first_weekday value from locale

From: Martin Norbäck (d95mback_at_dtek.chalmers.se)
Date: 2001-11-22 15:11:31

tor 2001-11-22 klockan 14.25 skrev Andries.Brouwer@cwi.nl:
>     The traditional first day of the week in Sweden is not Sunday, it's
>     Monday. Simple fact.
> 
>     > So, both are correct and very common.
> 
>     No. Monday is the first day of the week. Sunday have been in the past.
>     But not now.
> 
> You are contradicting yourself, or use `traditional' in a different
> way than I do.

Well, traditions change, but perhaps I should have chosen another word
to describe "what is used and what people have been using for some time
now". The Swedish standard changed in 1972, but people were already then
thinking about Monday as the first day of the week.

>     > It does not suffice to point at the locale.
>     > (Indeed, the locale is constant and does not distinguish countries,
>     > so asking glibc does not yield any information.)
> 
>     I don't understand what you mean by that.
>     sv_SE does not distinguish country? Then what is SE?
> 
> I mean that if you ask glibc what the first day of the week is,
> it never answers Sunday, independent of the locale.
> This means that asking glibc to find out whether it should be
> Sunday or Monday is meaningless, it is equivalent to always
> start at Monday.

Well, that's a deficiency in the current libc implementation if that's
the case, but on my system (using glibc 2.2.4).

martin@ivar:~$ LC_TIME=C locale first_weekday
7

which may or may not be Sunday, but it's definitely not Monday. A quick
look gives the following values to other locales:

fa_IR 7
japanese.sjis 7
POSIX 7

(all others have 1)

> Since the original cal program in Unix starts at Sunday, we may conclude
> that thirty years ago Sunday was what felt most natural to these
> authors. Don't know whether they would feel different today.
> You point out that some of these Swedish calendars were generated
> by American programs. Apparently the authors of these American programs
> felt that the week starts at Sunday.

Judging by my example you have the original Unix behaviour if you have C
as your locale, as many Americans do. Perhaps Americans think of Sunday
as the first day of the week. I don't know, because I am not American.

> I do not want to make a special Swedish exception in the cal source.

It's not a special Swedish exception, it's a step towards localisation
of the cal program.

> Referring to glibc does not work. There is clearly a use for
> calendars starting the week on Sunday.

It is you who is referring to glibc, not me. I am referring to locale
(the first_weekday field may or may not be present in all libc
implementations, but if it is, why not use it?).

There surely is a use for calendars starting the week on Sunday, but not
in Sweden, that's why first_weekday = 1 in sv_SE.

> Really, I cannot see any advantage in changing the default.
> These Swedes that cannot stand seeing a calendar start on Sunday
> may alias "cal" to "cal -m", or recompile cal with "#if 1" instead
> of "#if 0".

I can do it, (and I have), but that's hardly the point.

I don't want to overestimate the importance of the cal program, but I
really think this is a clear case where it's easy to follow the locale
settings, and therefore they should be followed. If the first day of the
week in Holland is Sunday, then the locale should be changed to reflect
that.

How about making the default locale-dependant and adding -s to force
Sunday as starting day? Or at least make it a compile time option to
avoid having to actually patch the source code.

Regards,

	Martin

-- 
[ http://www.dtek.chalmers.se/~d95mback/ ] [ PGP: 0x453504F1 ] [ UIN:
4439498 ]
    Opinions expressed above are mine, and not those of my future
employees.
SIGBORE: Signature boring error, core dumped

Arkiv genererat av hypermail 2.1.1.