doc: fix date(1) synopses etc

Font problem reported by Michael Aramini via Alejandro Colomar
<https://bugs.gnu.org/80258>.  This patch also fixes some
longstanding confusion with date synopses.
* src/date.c (usage): Do not imply that only -u can be used with
MMDDhhmm..., and do not put misleading brackets around the latter.
This commit is contained in:
Paul Eggert 2026-01-25 18:50:33 -08:00
parent 9cb06a7d13
commit f3980d7cfa
3 changed files with 26 additions and 21 deletions

View File

@ -15837,20 +15837,20 @@ Synopses:
@example
date [@var{option}]@dots{} [+@var{format}]
date [-u|--utc|--universal] @c this avoids a newline in the output
[ MMDDhhmm[[CC]YY][.ss] ]
date [@var{option}]@dots{} @c Avoid a newline in the output.
@var{mm}@var{dd}@var{hh}@var{mm}[[@var{cc}]@var{yy}][.@var{ss}]
@end example
The @command{date} command displays the date and time.
With the @option{--set} (@option{-s}) option, or with
@samp{MMDDhhmm[[CC]YY][.ss]},
it sets the date and time.
@samp{@var{mm}@var{dd}@var{hh}@var{mm}[[@var{cc}]@var{yy}][.@var{ss}]},
it sets the date and time before displaying it.
@vindex LC_TIME
Invoking @command{date} with no @var{format} argument is equivalent to invoking
Invoking @command{date} with no operands is equivalent to invoking
it with a default format that depends on the @env{LC_TIME} locale category.
In the default C locale, this format is @samp{'+%a %b %e %H:%M:%S %Z %Y'},
so the output looks like @samp{Thu Jul @ 9 17:00:00 EDT 2020}.
In the default C locale, this format is @samp{+%a %b %e %H:%M:%S %Z %Y},
so the output looks like @samp{Thu Jul @ 9 17:00:00 EDT 2026}.
@vindex TZ
Normally, @command{date} uses the time zone rules indicated by the
@ -15878,8 +15878,7 @@ is not set. @xref{TZ Variable,, Specifying the Time Zone with
@cindex time formats
@cindex formatting times
If given an argument that starts with a @samp{+}, @command{date} prints the
current date and time (or the date and time specified by the
@option{--date} option, see below) in the format defined by that argument,
date and time in the format defined by that argument,
which is similar to that of the @code{strftime} function. Except for
conversion specifiers, which start with @samp{%}, characters in the
format string are printed unchanged. The conversion specifiers are
@ -16283,26 +16282,26 @@ hardware clock may need to be updated from the system clock, which
might not happen automatically on your system.
To set the clock, you can use the @option{--set} (@option{-s}) option
(@pxref{Options for date}). To set the clock without using GNU
extensions, you can give @command{date} an argument of the form
@samp{MMDDhhmm[[CC]YY][.ss]} where each two-letter
(@pxref{Options for date}) or a operand of the form
@samp{@var{mm}@var{dd}@var{hh}@var{mm}[[@var{cc}]@var{yy}][.@var{ss}]}
where each two-letter
component stands for two digits with the following meanings:
@table @var
@item MM
month
@item DD
@item mm
month (this is the first @var{mm})
@item dd
day within month
@item hh
hour
@item mm
minute
@item CC
minute (this is the second @var{mm})
@item cc
first two digits of year (optional)
@item YY
@item yy
last two digits of year (optional)
@item ss
second (optional)
second (optional; this is a GNU extension)
@end table
The @option{--date} and @option{--set} options may not be used with an

View File

@ -1,5 +1,11 @@
[NAME]
date \- print or set the system date and time
[SYNOPSIS]
.B date
[\fI\,OPTION\/\fR]... [\fB+\fR\fI\,FORMAT\/\fR]
.br
.B date
[\fI\,OPTION\/\fR]... \fIMMDDhhmm\/\fR[[\fI\,CC\/\fR]\fI\,YY\/\fR][\fB.\fI\,ss\/\fR]
[DESCRIPTION]
.\" Add any additional description here
[DATE STRING]

View File

@ -128,12 +128,12 @@ usage (int status)
{
printf (_("\
Usage: %s [OPTION]... [+FORMAT]\n\
or: %s [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]\n\
or: %s [OPTION]... MMDDhhmm[[CC]YY][.ss]\n\
"),
program_name, program_name);
fputs (_("\
Display date and time in the given FORMAT.\n\
With -s, or with [MMDDhhmm[[CC]YY][.ss]], set the date and time.\n\
With -s, or with MMDDhhmm[[CC]YY][.ss], set the date and time first.\n\
"), stdout);
emit_mandatory_arg_note ();