Re: [RFC/PATCH] week numbers for cal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5 October 2013 21:59, Tommi Kyntola <tommi.kyntola@xxxxxxxxx> 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.
>
> I added -w|--week for showing week numbers. It defaults to North
> American numbering, because cal itself defaults to Sundays being the
> first day of the week. With Monday first it uses the ISO-8601 week
> numbers.
>
> I didn't worry too much about the implementation being as clean as
> possible just yet, but should this be deemed worth a jack, I or anyone
> else can take it to any direction.
>
> The three relevant patches are in my github:
> https://github.com/Kynde/util-linux.git
> https://github.com/Kynde/util-linux/commits
>
> Tommi Kyntola (4):
>       cal: added two missing tests
>       cal: added -w|--week for showing week numbers
>       cal: tests for week number modes added
>       cal: added more week number tests to cover various special cases
>
> The first that's on top of Karel's tree is a minor test fix for
> bigyear and sep1752 which seemed to lack final their last tests.
>
>  misc-utils/cal.c            |  140 +++-
>  tests/expected/cal/1mw      |   37 ++
>  tests/expected/cal/3mw      |   37 ++
>  tests/expected/cal/bigyear  |   51 ++
>  tests/expected/cal/bigyearw |  257 ++++++++
>  tests/expected/cal/colorw   |   55 ++
>  tests/expected/cal/sep1752  |   51 ++
>  tests/expected/cal/sep1752w |  249 ++++++++
>  tests/expected/cal/weeknum  | 1485 +++++++++++++++++++++++++++++++++++++++++++
>  tests/expected/cal/yearw    |  177 ++++++
>  tests/ts/cal/1mw            |   59 ++
>  tests/ts/cal/3mw            |   58 ++
>  tests/ts/cal/bigyear        |    1 +
>  tests/ts/cal/bigyearw       |   96 +++
>  tests/ts/cal/colorw         |   71 +++
>  tests/ts/cal/sep1752        |    1 +
>  tests/ts/cal/sep1752w       |   96 +++
>  tests/ts/cal/weeknum        |   87 +++
>  tests/ts/cal/yearw          |   58 ++
>  19 files changed, 3037 insertions(+), 29 deletions(-)
>
> Please cc me as I'm not on the list.

Hello Tommi,

Thank you for the weekday contribution. Earlier the year I though I'll
make this to work, but you were first.

I had look of your patch set and found out peculiarity. If the first
day of the week is highlighted the week number is calculated wrong.

$ cal -w 6 10 2013
      October 2013
   Su Mo Tu We Th Fr Sa
39        1  2  3  4  5
147  6  7  8  9 10 11 12
41 13 14 15 16 17 18 19
42 20 21 22 23 24 25 26
43 27 28 29 30 31

When day is not highlighted error does not occur.

$ cal --color=never -w 13 10 2013

-- 
Sami Kerola
http://www.iki.fi/kerolasa/
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux