[PATCH] util-linux-2.15/cal: cal date highlight enhancement

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

 



Hello,

Cal(1) highlights the current date when run normally and also with
the -3 and -y flags. But, this is not done when the current year is
requested explicitly like this:

$ cal 2009

The small patch below makes `cal 2009' behave like `cal -y', which I feel
should be the usual behaviour.

Thanks,
Rajeev

Signed-off-by: Rajeev V. Pillai <rajeevvp@xxxxxxxxx>

---- Start of Patch ----
diff -urN util-linux-ng-2.15.orig/misc-utils/cal.c util-linux-ng-2.15/misc-utils/cal.c
--- util-linux-ng-2.15.orig/misc-utils/cal.c	2009-03-25 17:50:18.000000000 +0530
+++ util-linux-ng-2.15/misc-utils/cal.c	2009-05-06 12:57:07.629295165 +0530
@@ -366,6 +366,11 @@
 			if (day > dm)
 				errx(1, _("illegal day value: use 1-%d"), dm);
 			day = day_in_year(day, month, year);
+		} else {
+			time(&now);
+			local_time = localtime(&now);
+			if (isatty(1) && ((local_time->tm_year + 1900) == year))
+				day = local_time->tm_yday + 1;
 		}
 		if (!month)
 			yflag=1;
---- End  of Patch ----
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux