bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] nstrftime: better width support for %N, %z


From: Kamil Dudka
Subject: Re: [PATCH] nstrftime: better width support for %N, %z
Date: Wed, 20 May 2020 19:51:45 +0200

On Friday, December 6, 2019 11:51:31 PM CEST Paul Eggert wrote:
> * lib/nstrftime.c (width_add, width_add1, width_cpy):
> New macros, which generalize ‘add’, ‘add1’, ‘cpy’ by adding
> a new WIDTH parameter.
> (add, add1, cpy): Use these macros.
> (width_add): Do not treat digits == 0 as a special case,
> do not pad if padding is ‘-’, and do not use a negative width.
> (__strftime_internal): Redo formatting of nanoseconds and numeric
> timezones to avoid buffer misuse in unusual cases, and so that
> widths make more sense.  Add support for widths greater than 9 to
> the %N format; they are zero filled on the right.
> * tests/test-nstrftime.c (posixtm_test): Add a %12N test.

This change caused the output of `date +%-N` to change in coreutils-8.32.

coreutils-8.31:
$ date +%-N -d 0:0:0.012345
12345000

coreutils-8.32:
$ date +%-N -d 0:0:0.012345
012345

The change broke scripts relying on the previous date's output:
https://github.com/kata-containers/runtime/issues/2692#issuecomment-631404726

If the change is intended, the documentation of `date` should be updated 
because it still says:

‘%N’
     nanoseconds (‘000000000’...‘999999999’).  This is a GNU extension.

‘-’
     (hyphen) Do not pad the field; useful if the output is intended for
     human consumption.  This is a GNU extension.

Kamil





reply via email to

[Prev in Thread] Current Thread [Next in Thread]