Pádraig Brady wrote:

> On 11/11/10 11:49, Jim Meyering wrote:
>> Paul Eggert wrote:
>>
>>> On 11/10/2010 01:04 AM, Jim Meyering wrote:
>>>> +      /* %.X   => precision defaults to 9
>>>> +         %.5X  => precision is 5
>>>> +         %#.X  => precision is determined by fstimeprec
>>>> +         %#.3X => precision is 3 (specified overrides "#")  */
>>>
>>> How about something like this instead?
>>>
>>>   %.X => precision is 9 (until POSIX goes sub-nanosecond :-)
>>>   %.5X => precision is 5
>>>   %.*X => precision determined by fstimeprec
>>>
>>> Then there's no reason for the "overrides" case.
>>
>> Good idea.  I prefer that.
>
> Well the reason I chose %#.X was that it was the
> standard mechanism for choosing "alternate form"
> and so was backwards compat with previous stats.
> I.E. on any stat "%#.X" would give the best
> available precision.

I prefer the "%.*X" notation because things to the right of the "."
denote precision.  It's slightly odd in that it looks like the invoker
might provide the actual number somehow, but once you know the rule
that precision comes from fstimeprec, it makes sense.

for i in $(seq 10); do
  touch -d '1970-01-01 18:43:33.5000000000' k
  src/stat -c "%.*Y" k
done

...
63813.50000000
63813.500000000
63813.5000000
63813.500000000



Reply via email to