Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#964566: ncal: please handle /usr/bin/cal + manpage via alternatives

1 view
Skip to first unread message

Thorsten Glaser

unread,
Jul 8, 2020, 3:20:03 PM7/8/20
to
Package: ncal
Version: 12.1.3
Severity: wishlist

Hi,

I’ve packaged (some time ago already) cal(1) from OpenBSD, because
it/its documentation guarantees a flag to get German calendar weeks
(KWs) as “kwal” (specifically for that).

While I’ve not (yet) uploaded this to Debian itself, kwal could
also provide cal(1) as ncal is available separately and these two
packages could handle this using alternatives.

Both their command line options and feature set differs. Check
http://www.mirbsd.org/~tg/Debs/dists/sid/wtf/Pkgs/kwal/ if you’re
interested.

-- System Information:
Debian Release: bullseye/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'oldstable-updates'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.7.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)

Versions of packages ncal depends on:
ii libc6 2.30-8
ii libtinfo6 6.2-1

ncal recommends no packages.

ncal suggests no packages.

Michael Meskes

unread,
Jul 13, 2020, 8:50:03 AM7/13/20
to
On Wed, Jul 08, 2020 at 09:13:50PM +0200, Thorsten Glaser wrote:
> I’ve packaged (some time ago already) cal(1) from OpenBSD, because
> it/its documentation guarantees a flag to get German calendar weeks
> (KWs) as “kwal” (specifically for that).

Could you please elaborate what (n)cal miss? "ncal -w" does give you week numbersand if you prefer the classical layout you could use "ncal -bw".

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

Thorsten Glaser

unread,
Jul 14, 2020, 7:50:02 AM7/14/20
to
Michael Meskes dixit:

>Could you please elaborate what (n)cal miss? "ncal -w" does give you
>week numbers

But which ones? American? German? ISO? (Turns out the latter two are
identical.) This is completely underdocumented and doesn’t match
expectations; even the “week begins with sunday/monday” knobs don’t
promise anything as the American and ISO ways of counting weeks are
still distinct.

It also has a different output format from traditional.

I understand if you find this too bothersome to do in Debian for
such a (corner?) case, but that is why this is of wishlist severity ;)

bye,
//mirabilos
--
<cnuke> den AGP stecker anfeilen, damit er in den slot aufm 440BX board passt…
oder netzteile, an die man auch den monitor angeschlossen hat und die dann für
ein elektrisch aufgeladenes gehäuse gesorgt haben […] für lacher gut auf jeder
LAN party │ <nvb> damals, als der pizzateig noch auf dem monior "gegangen" ist

Michael Meskes

unread,
Jul 14, 2020, 9:10:03 AM7/14/20
to
> >Could you please elaborate what (n)cal miss? "ncal -w" does give you
> >week numbers
>
> But which ones? American? German? ISO? (Turns out the latter two are

Depends on the locale you use.

> identical.) This is completely underdocumented and doesn’t match
> expectations; even the “week begins with sunday/monday” knobs don’t
> promise anything as the American and ISO ways of counting weeks are
> still distinct.

No idea what you are saying, sorry, please elaborate.

> It also has a different output format from traditional.

As mentioned in my previous email, you can use the -b switch to get
back to traditional format.

> I understand if you find this too bothersome to do in Debian for
> such a (corner?) case, but that is why this is of wishlist severity
> ;)

Na, the problem is understanding what's missing, or wrong. :)

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL

Thorsten Glaser

unread,
Jul 14, 2020, 4:30:02 PM7/14/20
to
Michael Meskes dixit:

>> >Could you please elaborate what (n)cal miss? "ncal -w" does give you
>> >week numbers
>>
>> But which ones? American? German? ISO? (Turns out the latter two are
>
>Depends on the locale you use.

The locale doesn’t contain enough information to calculate calendar weeks:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html

There’s neither a data field for the first day of the week, nor one for
the various ways to calculate a calendar week.

>No idea what you are saying, sorry, please elaborate.

There are multiple ways to calculate calendar weeks, see above.

>> I understand if you find this too bothersome to do in Debian for
>> such a (corner?) case, but that is why this is of wishlist severity
>> ;)
>
>Na, the problem is understanding what's missing, or wrong. :)

I think that while ncal may be a usable provider for cal, it’s not
suitable in all situations whereas the other implementation has its
benefit in some of these (but on the other hand lacking in cases
ncal supports) so we maybe should just have both?

Currently I just install kwal and call it as kwal, but with ncal
now being its separate package I just don’t need to install it any
more. This leaves cal(1) unprovided though so I came to consider
alternatives for it. Of course I could locally symlink it, but that
doesn’t scale, and Conflicts isn’t useful either so I can’t add the
symlinks to the kwal package.

In the end I just need a reliable way to get at German (= ISO)
calendar weeks, for use in business environments, and found that,
rather than having to write code myself, I could use OpenBSD’s cal,
which has an option for specifically this (although only for years
1753‥9999, same as ncal).

bye,
//mirabilos
--
(gnutls can also be used, but if you are compiling lynx for your own use,
there is no reason to consider using that package)
-- Thomas E. Dickey on the Lynx mailing list, about OpenSSL

Michael Meskes

unread,
Jul 15, 2020, 6:20:03 AM7/15/20
to
> The locale doesn’t contain enough information to calculate calendar
> weeks:
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html

Well, our locales do I think.

> There’s neither a data field for the first day of the week, nor one
> for
> the various ways to calculate a calendar week.

But there are, for instance:

michael@feivel:~$ locale -kc week-1stweek
LC_TIME
week-1stweek=1

> In the end I just need a reliable way to get at German (= ISO)
> calendar weeks, for use in business environments, and found that,
> rather than having to write code myself, I could use OpenBSD’s cal,
> which has an option for specifically this (although only for years
> 1753‥9999, same as ncal).

I haven't seen any error in ncal so far, but if you see some it might
be more helpful to report and/or fix those as ncal should not show
incorrect data.

Thorsten Glaser

unread,
Jul 15, 2020, 12:00:03 PM7/15/20
to
Michael Meskes dixit:

>> The locale doesnb t contain enough information to calculate calendar
>> weeks:
>> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html
>
>Well, our locales do I think.
>
>> Thereb s neither a data field for the first day of the week, nor one
>> for
>> the various ways to calculate a calendar week.
>
>But there are, for instance:
>
>michael@feivel:~$ locale -kc week-1stweek
>LC_TIME
>week-1stweek=1

Hrm, locale(5) shows…

week followed by a list of three values separated by semicolons: 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. See NOTES.

… but that’s neither accessible…

tglase@tglase-nb:~ $ locale -kc first_weekday
LC_TIME
first_weekday=1
tglase@tglase-nb:~ $ locale -kc week
locale: unknown name "week"

>I haven't seen any error in ncal so far, but if you see some it might

… nor does ncal use the locale for this, so, no, it does not use
appropriate calendar week calculation rules.

>be more helpful to report and/or fix those as ncal should not show

I’m honestly not interested in working on ncal, given I don’t even use
it and have a perfectly working implementation (I *did*, initially,
plan on patching ncal to support various standards for calendar week
calculation, until I found that OpenBSD’s cal already has them right).

bye,
//mirabilos
--
[...] if maybe ext3fs wasn't a better pick, or jfs, or maybe reiserfs, oh but
what about xfs, and if only i had waited until reiser4 was ready... in the be-
ginning, there was ffs, and in the middle, there was ffs, and at the end, there
was still ffs, and the sys admins knew it was good. :) -- Ted Unangst über *fs

Michael Meskes

unread,
Jul 15, 2020, 1:10:02 PM7/15/20
to
> >I haven't seen any error in ncal so far, but if you see some it
> might
>
> … nor does ncal use the locale for this, so, no, it does not use
> appropriate calendar week calculation rules.

This is simply not true since it definitely does.

> >be more helpful to report and/or fix those as ncal should not show
>
> I’m honestly not interested in working on ncal, given I don’t even
> use
> it and have a perfectly working implementation (I *did*, initially,
> plan on patching ncal to support various standards for calendar week
> calculation, until I found that OpenBSD’s cal already has them
> right).

Fair enough, but you could at least report these cases.

Thorsten Glaser

unread,
Jul 15, 2020, 3:00:02 PM7/15/20
to
Michael Meskes dixit:

>> b & nor does ncal use the locale for this, so, no, it does not use
>> appropriate calendar week calculation rules.
>
>This is simply not true since it definitely does.

I looked before writing that eMail, so it’s true; ncal uses the locale
to look up a country code, which then is used to determine the date of
the julian→gregorian calendar switch. That’s it exactly, nothing more.

>Fair enough, but you could at least report these cases.

Sure… if I see them.

bye,
//mirabilos
--
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent

Michael Meskes

unread,
Jul 16, 2020, 4:00:02 AM7/16/20
to
On Wed, 2020-07-15 at 18:50 +0000, Thorsten Glaser wrote:
> Michael Meskes dixit:
>
> >> b�& nor does ncal use the locale for this, so, no, it does not use
> >> appropriate calendar week calculation rules.
> >
> >This is simply not true since it definitely does.
>
> I looked before writing that eMail, so it’s true; ncal uses the
> locale
> to look up a country code, which then is used to determine the date
> of
> the julian→gregorian calendar switch. That’s it exactly, nothing
> more.

Huh? I don't think so:

$ grep -r nl_langinfo ncal/*
ncal/calendar.c: if ((wd = weekday(nd) + 1 - weekstart) >=
*nl_langinfo(_NL_TIME_WEEK_1STWEEK))
ncal/ncal.c: u.str = nl_langinfo(_NL_TIME_WEEK_1STDAY);
ncal/ncal.c: weekstart =
*nl_langinfo(_NL_TIME_FIRST_WEEKDAY) + (ndaysj(&first_week_d) -
ndaysj(&sunday)) % 7 - 1;

Thorsten Glaser

unread,
Jul 16, 2020, 8:10:03 AM7/16/20
to
Michael Meskes dixit:

>Huh? I don't think so:
>
>$ grep -r nl_langinfo ncal/*

Ah, I searched for locale, there’s another function…

… but they all look only for _NL_TIME_WEEK_1STWEEK, not for the
mode of how the weeks are calculated. I know at least two, ISO
(first week-of-year has at least 4 days/4ᵗʰ January/1ˢᵗ Thursday)
and USA (both 1ˢᵗ January *and* every Sunday begin a new week,
so short weeks are possible).

bye,
//mirabilos
--
Solange man keine schmutzigen Tricks macht, und ich meine *wirklich*
schmutzige Tricks, wie bei einer doppelt verketteten Liste beide
Pointer XORen und in nur einem Word speichern, funktioniert Boehm ganz
hervorragend. -- Andreas Bogk über boehm-gc in d.a.s.r

Michael Meskes

unread,
Jul 16, 2020, 9:00:03 AM7/16/20
to
> … but they all look only for _NL_TIME_WEEK_1STWEEK, not for the
> mode of how the weeks are calculated. I know at least two, ISO

In fact there are three different queries, for _NL_TIME_WEEK_1STWEEK,
_NL_TIME_WEEK_1STDAY, and _NL_TIME_FIRST_WEEKDAY.

> (first week-of-year has at least 4 days/4ᵗʰ January/1ˢᵗ Thursday)
> and USA (both 1ˢᵗ January *and* every Sunday begin a new week,
> so short weeks are possible).

Do you have any documentation about the US system that is kind of
official? I doubt anyone in the States uses week numbers, but there may
be an official way nonetheless.

Thorsten Glaser

unread,
Jul 16, 2020, 12:00:02 PM7/16/20
to
Michael Meskes dixit:

>Do you have any documentation about the US system that is kind of
>official? I doubt anyone in the States uses week numbers, but there may
>be an official way nonetheless.

https://de.wikipedia.org/wiki/Woche#Berechnung_in_den_USA_und_vielen_anderen_L%C3%A4ndern
so far, plus the fact that many tools show wrong week numbers for Europeans
while Americans complain about wrong week numbers in other tools.

Also as an example:

$ kwal -mw 1 2005
January 2005
Mo Tu We Th Fr Sa Su
1 2 [53]
3 4 5 6 7 8 9 [ 1]
10 11 12 13 14 15 16 [ 2]
17 18 19 20 21 22 23 [ 3]
24 25 26 27 28 29 30 [ 4]
31 [ 5]
$ kwal -w 1 2005
January 2005
Su Mo Tu We Th Fr Sa
1 [ 1]
2 3 4 5 6 7 8 [ 2]
9 10 11 12 13 14 15 [ 3]
16 17 18 19 20 21 22 [ 4]
23 24 25 26 27 28 29 [ 5]
30 31 [ 6]
$ ncal -w 1 2005
January 2005
Su 2 9 16 23 30
Mo 3 10 17 24 31
Tu 4 11 18 25
We 5 12 19 26
Th 6 13 20 27
Fr 7 14 21 28
Sa 1 8 15 22 29
52 1 2 3 4 5

The first one is correct for Germany. The second one is correct for USA
according to that documentation above. The third… whatever it is, is what
ncal does.

Michael Meskes

unread,
Jul 17, 2020, 5:10:03 AM7/17/20
to
On Thu, Jul 16, 2020 at 03:43:24PM +0000, Thorsten Glaser wrote:
> Michael Meskes dixit:
>
> >Do you have any documentation about the US system that is kind of
> >official? I doubt anyone in the States uses week numbers, but there may
> >be an official way nonetheless.
>
> https://de.wikipedia.org/wiki/Woche#Berechnung_in_den_USA_und_vielen_anderen_L%C3%A4ndern

Oh right, the German version knows how it's done in the States but the English
one doesn't. Please excuse me if I don't really accept this as fact,
particularly as the page itself claims that the information is not verifiable
and needs references.
Unfortunately you didn't tell us which locale you ran it under, but anyway,
let's have a look:

$ export LC_ALL=de_DE.UTF8; ncal -bw 1 2005

Januar 2005
w| Mo Di Mi Do Fr Sa So
53| 1 2
1| 3 4 5 6 7 8 9
2| 10 11 12 13 14 15 16
3| 17 18 19 20 21 22 23
4| 24 25 26 27 28 29 30
5| 31

Except for formatting changes this is exactly your case 1, right?

As for the second, see above. Unless proven wrong I stick with what the locale
gives me.

Michael

--
Michael Meskes
Michael at Fam-Meskes dot De

Thorsten Glaser

unread,
Jul 17, 2020, 10:10:03 AM7/17/20
to
Michael Meskes dixit:

>As for the second, see above. Unless proven wrong I stick with what the locale
>gives me.

Funny thing, I just checked what strftime does; POSIX is a bit more
explanatory than the BSD manpages here, so quoting it:

U
Replaced by the week number of the year as a decimal number
[00,53]. The first Sunday of January is the first day of week
1; days in the new year before this are in week 0. [ tm_year,
tm_wday, tm_yday]

So, basically the same as kwal just with one subtracted if 1ˢᵗ January
is not a Sunday.

This is *fun*! (Sarcasm detector please enable yourself.)


OK, back to the original question at hand: managing cal(1) with
Debian alternatives.

bye,
//mirabilos
--
[00:02] <Vutral> gecko: benutzt du emacs ?
[00:03] <gecko> nö [00:03] <gecko> nur n normalen mac
[00:04] <Vutral> argl [00:04] <Vutral> ne den editor
-- Vutral und gecko2 in #deutsch (NB: Editor? Betriebssystem.)
0 new messages