On 5/20/20 10:51 AM, Kamil Dudka wrote:
If the change is intended, the documentation of `date` should be updated

Thanks for mentioning this. The change was intended, and I installed the attached patch into the Coreutils documentation.
>From 6d0107a37f3b648aa43bf790625dd25f9f8301e7 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Wed, 20 May 2020 17:31:18 -0700
Subject: [PATCH] date: document +%-N change

Suggested by Kamil Dudka in:
https://lists.gnu.org/r/bug-gnulib/2020-05/msg00205.html
* NEWS: Mention the change for coreutils 8.23.
* doc/coreutils.texi (Padding and other flags):
Document it.
---
 NEWS               |  5 +++++
 doc/coreutils.texi | 10 +++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 1f59a156a..8ddd0e22f 100644
--- a/NEWS
+++ b/NEWS
@@ -90,6 +90,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   [The old behavior was introduced in sh-utils 2.0.15 ca. 1999, predating
   coreutils package.]
 
+  date now pads nanoseconds on the right, not the left.  For example,
+  if the time is currently 1590020079.003388470 seconds after the
+  Epoch, then "date '+%s.%-N'" formerly output "1590020079.3388470",
+  and it now outputs "1590020079.00338847".
+
   ls issues an error message on a removed directory, on GNU/Linux systems.
   Previously no error and no entries were output, and so indistinguishable
   from an empty directory, with default ls options.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 0e1dc48bd..f0684b1c5 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -16034,7 +16034,10 @@ a horizontal tab
 Unless otherwise specified, @command{date} normally pads numeric fields
 with zeros, so that, for
 example, numeric months are always output as two digits.
-Seconds since the epoch are not padded, though,
+Most numeric fields are padded on the left.
+However, nanoseconds are padded on the right since they are commonly
+used after decimal points in formats like @samp{%s.%-N}.
+Also, seconds since the epoch are not padded
 since there is no natural width for them.
 
 The following optional flags can appear after the @samp{%}:
@@ -16082,9 +16085,10 @@ date +%_d/%_m -d "Feb 1"
 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
+the result is normally written right adjusted and padded to the given
 size.  For example, @samp{%9B} prints the right adjusted month name in
-a field of width 9.
+a field of width 9.  Nanoseconds are left adjusted, and are truncated
+or padded to the field width.
 
 An optional modifier can follow the optional flag and width
 specification.  The modifiers are:
-- 
2.25.4

Reply via email to