Re: [coreutils] Re: [PATCH 2/2] stat: print timestamps to full resolutio
From:
Jim Meyering
Subject:
Re: [coreutils] Re: [PATCH 2/2] stat: print timestamps to full resolution
Date:
Thu, 21 Oct 2010 17:54:22 +0200
Eric Blake wrote:
> On 10/21/2010 09:33 AM, Jim Meyering wrote:
>>> Then, to get full seconds.nanoseconds, you'd use a format like %X.%:X
>>> and if you want only milliseconds, you'd use %X.%3.3:X
>>
>> Oops.
>> I forgot to zero-pad. Otherwise, with< 100,000,000ns in the first
>> case or< 100 in the 2nd, and the above would print invalid numbers.
>>
>> This is the right way:
>>
>> To get full seconds.nanoseconds, you'd use a format like %X.%0:X
>> and if you want only milliseconds, you'd use %X.%03.3:X
>
> Do we really want to require that users must manually 0-pad, or can we
> explicitly state that %:X has a minimum width of min(precision,9), and
> 0 padding is only needed if you want a width greater than 9.
That would be better, since I suspect there are very
few uses of %:X that would *not* want leading zeros.
Otherwise, we'd be setting up users of this feature
for an insidious bug.