Rajeev V. Pillai wrote: > On Wed, 6 May 2009, Pádraig Brady wrote: > >> Rajeev V. Pillai wrote: >>> 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. I think that's better. >> I'd prefer doing like this though... >> > > No problem--it's your show. Cool. Karel please `git am` the attached. cheers, Pádraig.
>From 9c0bce4ea71620e5641a0d91f7b371bc20fb662a Mon Sep 17 00:00:00 2001 From: Rajeev V. Pillai <rajeevvp@xxxxxxxxx> Date: Wed, 6 May 2009 12:23:45 +0100 Subject: [PATCH] cal: Highlight today even when month or year specified MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit * misc-utils/cal.c: Unconditionally call time() and highlight today where possible. Signed-off-by: Pádraig Brady <P@xxxxxxxxxxxxxx> --- misc-utils/cal.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/misc-utils/cal.c b/misc-utils/cal.c index 2417f1b..f2d52e8 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -348,6 +348,9 @@ main(int argc, char **argv) { argc -= optind; argv += optind; + time(&now); + local_time = localtime(&now); + day = month = year = 0; switch(argc) { case 3: @@ -366,13 +369,13 @@ main(int argc, char **argv) { if (day > dm) errx(1, _("illegal day value: use 1-%d"), dm); day = day_in_year(day, month, year); + } else if ((local_time->tm_year + 1900) == year) { + day = local_time->tm_yday + 1; } if (!month) yflag=1; break; case 0: - time(&now); - local_time = localtime(&now); day = local_time->tm_yday + 1; year = local_time->tm_year + 1900; month = local_time->tm_mon + 1; -- 1.5.3.6