cal -w and ISO weeks
Hi,
fiddling around with 'cal -w' made me stumble in 2021:
% cal -w 1 2021
January 2021 Su Mo Tu We Th Fr Sa 1 1 2 2 3 4 5 6 7 8 9
3 10 11 12 13 14 15 16
4 17 18 19 20 21 22 23
5 24 25 26 27 28 29 30
6 31
Obviously these week numbers are not ISO weeks. The manpage says:
-w, --week[=number]
Display week numbers in the calendar (US or ISO-8601).
So the next thing I tried was:
% cal --iso -w 1 2021
January 2021 Su Mo Tu We Th Fr Sa 1 1 2 2 3 4 5 6 7 8 9
3 10 11 12 13 14 15 16
4 17 18 19 20 21 22 23
5 24 25 26 27 28 29 30
6 31
I actually had to read the OpenBSD man pages to see what's going on:
-w Display week numbers in the month display. If -m is specified
the ISO week format is assumed. The options -j and -w are mutually exclusive.
Finally:
% cal -m -w 1 2021
January 2021 Mo Tu We Th Fr Sa Su 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
So, to avoid further confusion, I'd propose to:
1) Reword the description of -w in the man page cal(1).
2) Rethink if --iso shouldn't also imply -m, as implied by ISO-8601.
Thanks,
Signature · 1 line
Leah Neukirchen <[email protected]> https://leahneukirchen.org/
Karel Zak
maintainerQuoted 3 lines · Leah Neukirchen
So, to avoid further confusion, I'd propose to:
1) Reword the description of -w in the man page cal(1).
Fixed (we already have a note about it in NOTES section, but it's somehow pretty hidden at the first glance).
https://github.com/karelzak/util-linux/commit/261cf856277f5e7e4815c211fe48b97746d5d3a3
Quoted 1 line
2) Rethink if --iso shouldn't also imply -m, as implied by ISO-8601.
Good point, sounds like user-friendly change (although it is not 100% backwardly compatible).
William, what about to automatically use -m (start week at Monday) when --iso specified on command line? It means not keep --iso only as way to switch calendars, but also as a general option to get ISO-8601. (Not sure, may be we already discussed this years ago.)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com