Re: [RFC/PATCH] week numbers for cal

Karel Zak
2013-10-22T10:32:21Z

On Sat, Oct 05, 2013 at 11:59:54PM +0300, Tommi Kyntola wrote:
> I keep trying -w with cal from time to time and I finally decided it's
> about time to do something about it. I'm not sure if this is something
> you'd be interested in incorporating into util-linux cal, but it's
> something I wanted, so here it is. There's gcal of course, but I only
> wanted a toothpick not the whole forest.

Applied, thanks.

Comments:

* please, next time always use space around operators and after
commas, things like

week_number(xd&~TODAY_FLAG,month+which_cal+1,year,wflag);

are horrible.

* I don't understand this feature:

/* In some years (e.g. 2010 in ISO mode) it's possible to
* have a remnant of week 53 starting the year yet the year
* in question ends during 52, in this case we're assuming
* that early remnant is being referred to if 53 is given
* as argument. */

For example:

$ LANG=de_DE.UTF8 ./cal --week=53 2009
Dezember 2009
Mo Di Mi Do Fr Sa So
49 1 2 3 4 5 6
50 7 8 9 10 11 12 13
51 14 15 16 17 18 19 20
52 21 22 23 24 25 26 27
53 28 29 30 31

it's correct, let's try the next year:

$ LANG=de_DE.UTF8 ./cal --week=53 2010
Januar 2010
Mo Di Mi Do Fr Sa So
53 1 2 3
1 4 5 6 7 8 9 10
2 11 12 13 14 15 16 17
3 18 19 20 21 22 23 24
4 25 26 27 28 29 30 31

oh... week 53 of the year 2010 in January 2010, but week 52 is December:

$ LANG=de_DE.UTF8 ./cal --week=52 2010
Dezember 2010
Mo Di Mi Do Fr Sa So
48 1 2 3 4 5
49 6 7 8 9 10 11 12
50 13 14 15 16 17 18 19
51 20 21 22 23 24 25 26
52 27 28 29 30 31

It seems pretty strange to interpret --week=53 2010 as last week
of the year 2009. I think it would be more intuitive to interpret

cal --week=53 2010

as invalid week number (or for another years expect this week after
week 52).

Note that I'm talking about command line --week=53 interpretations, the
week numbers in the output are correct of course.

Karel

--
Karel Zak <kzak@redhat.com>