]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
date: ‘+’ conversion specification flag
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 25 Feb 2019 07:59:22 +0000 (23:59 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 25 Feb 2019 07:59:55 +0000 (23:59 -0800)
The recent Gnulib update fixed Bug#34608; document and test this.
* NEWS: Mention the change.
* doc/coreutils.texi (Padding and other flags):
Update doc to cover new flag and other POSIX.1-2017 changes.
* tests/misc/date.pl (date-century-plus): New test.

NEWS
doc/coreutils.texi
tests/misc/date.pl

diff --git a/NEWS b/NEWS
index 5d9956854e59271ce382024108ac61df6b94cd95..e73cb52b8303ff223039ffe8c9d25e83b8044284 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   after asking the user whether to proceed.
   [This bug was present in "the beginning".]
 
+  'date' now supports the '+' conversion specification flag,
+  introduced in POSIX.1-2017.
+
   df no longer corrupts displayed multibyte characters on macOS.
   [bug introduced with coreutils-8.18]
 
index 028371673b51f87da7a683ed85bb8675616baf1d..d1427323cc0ff1f213e414eedd5e086d29362557 100644 (file)
@@ -15985,24 +15985,33 @@ example, numeric months are always output as two digits.
 Seconds since the epoch are not padded, though,
 since there is no natural width for them.
 
-As a GNU extension, @command{date} recognizes any of the
-following optional flags after the @samp{%}:
+The following optional flags can appear after the @samp{%}:
 
 @table @samp
 @item -
 (hyphen) Do not pad the field; useful if the output is intended for
 human consumption.
+This is a GNU extension.
 @item _
 (underscore) Pad with spaces; useful if you need a fixed
 number of characters in the output, but zeros are too distracting.
+This is a GNU extension.
 @item 0
 (zero) Pad with zeros even if the conversion specifier
 would normally pad with spaces.
+@item +
+Pad with zeros, like @samp{0}.  In addition, precede any year number
+with @samp{+} if it exceeds 9999 or if its field width exceeds 4;
+similarly, precede any century number with @samp{+} if it exceeds 99
+or if its field width exceeds 2.  Preceding with @samp{+} is helpful
+for generationg some ISO 8601 formats.
 @item ^
 Use upper case characters if possible.
+This is a GNU extension.
 @item #
 Use opposite case characters if possible.
 A field that is normally upper case becomes lower case, and vice versa.
+This is a GNU extension.
 @end table
 
 @noindent
@@ -16017,7 +16026,7 @@ date +%_d/%_m -d "Feb 1"
 @result{}  1/ 2
 @end example
 
-As a GNU extension, you can specify the field width
+You can optionally specify the field width
 (after any flag, if present) as a decimal number.  If the natural size of the
 output of the field has less than the specified number of characters,
 the result is written right adjusted and padded to the given
index 5e12158e94d61bb7b5cfd58cc5e722f08490ac40..9ba3d39839ba85906a14797c617848ad8c66f4ab 100755 (executable)
@@ -297,6 +297,9 @@ my @Tests =
       {ENV => 'TZ=PST8'},
       {OUT => 'Wed Dec 31 21:00:00 PST 1969'},
      ],
+
+     # https://bugs.gnu.org/34608
+     ['date-century-plus', '-d @0 +.%+4C.', {OUT => '.+019.'}],
     );
 
 # Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.