summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRajeev V. Pillai2009-05-06 13:23:45 +0200
committerKarel Zak2009-05-07 10:59:29 +0200
commita43145e157467ca281264e6571f27c014957e5dc (patch)
tree6a9f0bad6be62c2fabd3ca45b879bfdf11868d7d
parentbuild-sys: release++ (v2.15) (diff)
downloadkernel-qcow2-util-linux-a43145e157467ca281264e6571f27c014957e5dc.tar.gz
kernel-qcow2-util-linux-a43145e157467ca281264e6571f27c014957e5dc.tar.xz
kernel-qcow2-util-linux-a43145e157467ca281264e6571f27c014957e5dc.zip
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>
-rw-r--r--misc-utils/cal.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 2417f1b5a..f2d52e8cb 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;