2 ms·
My first solution in shell would have been horribly unportable across locales (though perhaps adding LC_ALL=C would fix that): echo $(($(cal -3|cut -c13-14|g
by aidenn0 5y ago
My first solution in shell would have been horribly unportable across locales (though perhaps adding LC_ALL=C would fix that):
echo $(($(cal -3|cut -c13-14|grep -cv ' ')-2))
+ cal -3 will print 3 months spanning the current date(default horizontal on most modern cal implementations).
+ Grab characters 13,14 (the Thursday column of the first month).
+ grep to eliminate blank entries
+ There is no English language month+4 digit year that will not have at least 1 character in the Thursday column, and of course the "Th" header is also there, so subtract 2 from the result