]> err.no Git - util-linux/commitdiff
cal: Highlight today even when month or year specified
authorRajeev V. Pillai <rajeevvp@gmail.com>
Wed, 6 May 2009 11:23:45 +0000 (12:23 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 7 May 2009 08:59:29 +0000 (10:59 +0200)
* 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>
misc-utils/cal.c

index 2417f1b5a999f0546d16a46dc1e85d937bafb671..f2d52e8cbc7bff372e9075b4d7af6c1255e5dbfb 100644 (file)
@@ -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;