.br
.B cal
[options]
-.RI <timestamp>
+.RI <timestamp|monthname>
.SH DESCRIPTION
.B cal
displays a simple calendar. If no arguments are specified, the current
.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
if (argc == 1 && !isdigit_string(*argv)) {
usec_t x;
+ /* cal <timestamp> */
if (parse_timestamp(*argv, &x) == 0)
now = (time_t) (x / 1000000);
+ /* cal <monthname> */
+ 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);
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);
{
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [[[day] month] year]\n"), program_invocation_short_name);
+ fprintf(out, _(" %s [options] <timestamp|monthname>\n"), program_invocation_short_name);
fputs(USAGE_SEPARATOR, out);
fputs(_("Display a calendar, or some part of it.\n"), out);