tech-userlevel archive

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

Re: Weekday abbreviations in output of cal(1)



TL`DR:  I wouldn't mind the SuMoTuWeThFrSa change in cal(1)
but I don't really give a damn either way.

MS>  Well, how would you use date(1) to return the number of days in any
MS>  given month, for example?

	% xargs -I MON date -d '1-MON +1 month -1 day' +'%m %d'
	july
	07 31
	june
	06 30
	jan
	01 31
	^D

I side with Martin Husemann:  most of the calendar-oriented scripting
in my career is based on date(1) rather than cal(1),  even though
the date(1) parsing syntax varies *wildly* between Unix/Linux versions.[*]

Note that OpenBSD has the English two-letter weekdays hard-wired
in /usr/src/usr.bin/cal/cal.c whereas the Linux and FreeBSD cal(1)
versions actually respect the LC_TIME locale setting.  Your goal
of "aligning NetBSD with the rest" is a bit ephemeral because
the rest isn't really aligned, either.

Personally, I care very little about single vs double letter weekdays
in the cal(1) header.  POSIX says I shouldn't (the heading is unspecified).
I'd consider a consistent 1- or 2-lettering aesthetically more
pleasing and an improvement wortwhile enough to break compatibility
with the past.

We all can even tell which "S" is supposed to be what day.  Incidentally,
where I live (Northern Germany) these two days happen to be called

	Sonnabend
	Sonntag

I'd prefer compact columns instead of getting this oh-so-dreadful
ambiguity in the five initial letters resolved :-)

							Martin Neitzel

PS:  MUCH more useful to me is a cal(1) option to put Mondays first.
(I use cal(1) daily in the office.)

With the NetBSD cal(1) we can even pull any weekday in front.  For
scripting on weekdays, I would go via this route instead of relying
on the weekday lettering.   This month's Thursdays:

	% cal -d 4 | sed -n 's/^\(.[0-9]\).*/\1/p'
	 2
	 9
	16
	23
	30

[*] and PPS:  I happen to be able to find "next month's first Thursday"
using FreeBSDs date(1) easily:

	% date -v1d -v+1m -v+thu 
	Thu Aug  6 15:55:05 CEST 2020

I am not 100% sure how to do the job with NetBSD's date(1).  I may
be just lucky with

	% date -d '+1 month 1 thu'
	Thu Aug  6 00:00:00 CEST 2020

because today is the 1st of July.  I better recheck this in a fortnight.



Home | Main Index | Thread Index | Old Index