[Nottingham] HOT Dating one-liner contest
Jason Cozens
jason.cozens at computer.org
Mon Jan 14 20:28:42 GMT 2008
> Yeah... well, I feel opportunities for language golf should never pass
> by. Besides, I wonder when the last Haskell proponent popped up here. :)
>
This isn't a hole-in-one but I've been looking at awk recently, so:
BEGIN {
printf("\n%-40s%s\n\n", "First Wednesday", "Following Third Thursday")
for (m = 1; m <= 12; m++) {
for (d = 1; d <= 7; d++) {
date = mktime("2008 " m " " d " 12 00 00")
if (strftime("%A", date) == "Wednesday") {
printf("%-40s ", strftime("%A, %B %d,
%Y", date))
thur = mktime("2008 " m " " d + 15 " 12 00 00")
printf("%s\n", strftime("%A, %B %d, %Y", thur))
}
}
}
}
$ gawk -f thirdthurs.awk
First Wednesday Following Third Thursday
Wednesday, January 02, 2008 Thursday, January 17, 2008
Wednesday, February 06, 2008 Thursday, February 21, 2008
Wednesday, March 05, 2008 Thursday, March 20, 2008
Wednesday, April 02, 2008 Thursday, April 17, 2008
Wednesday, May 07, 2008 Thursday, May 22, 2008
Wednesday, June 04, 2008 Thursday, June 19, 2008
Wednesday, July 02, 2008 Thursday, July 17, 2008
Wednesday, August 06, 2008 Thursday, August 21, 2008
Wednesday, September 03, 2008 Thursday, September 18, 2008
Wednesday, October 01, 2008 Thursday, October 16, 2008
Wednesday, November 05, 2008 Thursday, November 20, 2008
Wednesday, December 03, 2008 Thursday, December 18, 2008
It needs a fixed width font to look good.
Cheers,
Jason.
More information about the Nottingham
mailing list