From: Paul Eggert Date: Mon, 25 Feb 2019 18:20:23 +0000 (-0800) Subject: doc: more date +%F clarifications X-Git-Tag: v8.31~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ab2f7a422652a9ec887e08ca8935b44e9629505;p=thirdparty%2Fcoreutils.git doc: more date +%F clarifications * doc/coreutils.texi (Date conversion specifiers): Plain %F is actually like %+4Y-%m-%d. (Padding and other flags): Mention POSIX restrictions. * src/date.c (usage): Document recent changes. --- diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 3eedd3c63e..eb18488829 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -15896,7 +15896,9 @@ date; same as @samp{%m/%d/%y} @item %e day of month, space padded; same as @samp{%_d} @item %F -full date in ISO 8601 format; same as @samp{%Y-%m-%d}. +full date in ISO 8601 format; like @samp{%+4Y-%m-%d} +except that any flags or field width override the @samp{+} +and (after subtracting 6) the @samp{4}. This is a good choice for a date format, as it is standard and is easy to sort in the usual case where years are in the range 0000@dots{}9999. @@ -16053,6 +16055,12 @@ applies only to numeric conversion specifiers. If the format supports the modifier but no alternate representation is available, it is ignored. +POSIX specifies the behavior of flags and field widths only for +@samp{%C}, @samp{%F}, @samp{%G}, and @samp{%Y} (all without +modifiers), and requires a flag to be present if and only if a field +width is also present. Other combinations of flags, field widths and +modifiers are GNU extensions. + @node Setting the time @subsection Setting the time diff --git a/src/date.c b/src/date.c index 6904eeadb1..d97d0ae52c 100644 --- a/src/date.c +++ b/src/date.c @@ -194,7 +194,7 @@ FORMAT controls the output. Interpreted sequences are:\n\ %e day of month, space padded; same as %_d\n\ "), stdout); fputs (_("\ - %F full date; same as %Y-%m-%d\n\ + %F full date; like %+4Y-%m-%d\n\ %g last two digits of year of ISO week number (see %G)\n\ %G year of ISO week number (see %V); normally useful only with %V\n\ "), stdout); @@ -253,6 +253,7 @@ The following optional flags may follow '%':\n\ - (hyphen) do not pad the field\n\ _ (underscore) pad with spaces\n\ 0 (zero) pad with zeros\n\ + + pad with zeros, and put '+' before future years with >4 digits\n\ ^ use upper case if possible\n\ # use opposite case if possible\n\ "), stdout);