diff --git a/misc-utils/cal.1 b/misc-utils/cal.1 index 2048e95e2..39378cfe2 100644 --- a/misc-utils/cal.1 +++ b/misc-utils/cal.1 @@ -44,7 +44,7 @@ cal \- display a calendar .br .B cal [options] -.RI +.RI .SH DESCRIPTION .B cal displays a simple calendar. If no arguments are specified, the current @@ -103,10 +103,13 @@ Specifies the \fIyear\fR to be displayed; note the year must be fully specified: .B "cal 89" will not display a calendar for 1989. .TP -\fBSingle string parameter (e.g. 'cal tomorrow')\fR -Specifies \fItimestamp\fR. The special placeholders are accepted when parsing timestamp, "now" may be used to -refer to the current time, "today", "yesterday", "tomorrow" refer to -of the current day, the day before or the next day, respectively. +\fBSingle string parameter (e.g. 'cal tomorrow' or 'cal August')\fR +Specifies \fItimestamp\fR or a \fImonth name\fR according to the current +locales. +.sp +The special placeholders are accepted when parsing timestamp, "now" may be used +to refer to the current time, "today", "yesterday", "tomorrow" refer to of the +current day, the day before or the next day, respectively. .sp The relative date specifications are also accepted, in this case "+" is evaluated to the current time plus the specified time span. Correspondingly, a diff --git a/misc-utils/cal.c b/misc-utils/cal.c index aaa2943e6..5c56e7480 100644 --- a/misc-utils/cal.c +++ b/misc-utils/cal.c @@ -410,10 +410,14 @@ int main(int argc, char **argv) if (argc == 1 && !isdigit_string(*argv)) { usec_t x; + /* cal */ if (parse_timestamp(*argv, &x) == 0) now = (time_t) (x / 1000000); + /* cal */ + else if ((ctl.req.month = monthname_to_number(&ctl, *argv)) > 0) + time(&now); /* this year */ else - errx(EXIT_FAILURE, _("failed to parse timestamp")); + errx(EXIT_FAILURE, _("failed to parse timestamp or unknown month name: %s"), *argv); argc = 0; } else time(&now); @@ -460,7 +464,8 @@ int main(int argc, char **argv) case 0: ctl.req.day = local_time->tm_yday + 1; ctl.req.year = local_time->tm_year + 1900; - ctl.req.month = local_time->tm_mon + 1; + if (!ctl.req.month) + ctl.req.month = local_time->tm_mon + 1; break; default: usage(stderr); @@ -969,6 +974,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out) { fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] [[[day] month] year]\n"), program_invocation_short_name); + fprintf(out, _(" %s [options] \n"), program_invocation_short_name); fputs(USAGE_SEPARATOR, out); fputs(_("Display a calendar, or some part of it.\n"), out);