diff options
author | Rajeev V. Pillai <rajeevvp@gmail.com> | 2009-05-06 12:23:45 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2009-05-27 10:20:59 +0200 |
commit | 2670086905b0721af123670c240e8fbc159c446d (patch) | |
tree | 6a9f0bad6be62c2fabd3ca45b879bfdf11868d7d /misc-utils | |
parent | 676c8bfa7815a3be3fe07d83c043a65610650682 (diff) | |
download | util-linux-old-2670086905b0721af123670c240e8fbc159c446d.tar.gz |
cal: Highlight today even when month or year specified
* misc-utils/cal.c: Unconditionally call time()
and highlight today where possible.
Signed-off-by: Rajeev V. Pillai <rajeevvp@gmail.com>
Signed-off-by: Pádraig Brady <P@draigBrady.com>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | 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 2417f1b5..f2d52e8c 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; |