bug-findutils
[Top][All Lists]
Advanced

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

[bug #22662] incomplete documentation for sub-second time stamps in find


From: James Youngman
Subject: [bug #22662] incomplete documentation for sub-second time stamps in find -printf format specifiers
Date: Fri, 21 Mar 2008 15:24:10 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080129 Iceweasel/2.0.0.12 (Debian-2.0.0.12-1)

Follow-up Comment #1, bug #22662 (project findutils):

Yes, the %AX problem is indeed a bug, and thanks for letting us know about
it.

%AX uses the strftime format %X.  That yields the locale's preferred time
representation:-

$ for locale in POSIX fr_FR.UTF-8  en_IE.UTF-8 en_US.UTF-8; do printf "%-13s
[%s]n" "$locale" "$(LC_ALL=$locale  date +%X)"; done
POSIX         [14:31:09]
fr_FR.UTF-8   [14:31:09]
en_IE.UTF-8   [14:31:09]
en_US.UTF-8   [02:31:09 PM]

It looks like the en_US.UTF-8 locale uses the %r format for strftime's %X
format.  POSIX allows us to determine what format is being used by calling
nl_langinfo():

$ LC_ALL=en_US.UTF-8 ./locale_time_formats 
POSIX locale:
D_T_FMT   : [%a %b %e %H:%M:%S %Y]
D_FMT     : [%m/%d/%y]
T_FMT     : [%H:%M:%S]
en_US.UTF-8 locale:
D_T_FMT   : [%a %d %b %Y %r %Z]
D_FMT     : [%m/%d/%Y]
T_FMT     : [%r]

On the other hand my locale has T_FMT=%T.   It should be safe to append
nanoseconds for formats where T_FMT yields just %S (won't happen), %T, or %s
(also won't happen), or where the format ends in %S.

If we know the locale is POSIX, we could manually translate %r to 
 %I:%M:%S %p so that the %S expands correctly, and we can probably do that in
all cases for %T.

However, there is another likely bug in the implementation.  It hard-codes
the use of "." as the radix character instead of using  the value of
RADIXCHAR.

However, these things would be hard to document.  How about doing things this
way:

1. In the POSIX locale, the seconds field always includes a fractional part,
for all formats.

2. In locales other than POSIX, the only fields for which find will include
nanoseconds are %[ACT]S, %[ACT}+, %[ACT]@ and %[ACT]T, and in those cases the
locale's radix character will separate the whole part and the fractional part.
  In locales where the strftime formats %X and %T are identical, this will
also happen for %[ACT]X.  (Here, "%[ACT]X" means "%AX, %CX or %TX").

3. In other cases the seconds field may lack a fractional part.

In terms of what will change with respect to 4.4.0:
a) No change in the POSIX locale
b) Change in behaviour of %AX, %CX, %TX for non-POSIX locales.
c) Use of radix character where appropriate, versus "." previously.

The upside of this approach is that it is relatively easy to document and the
behavioural change is small.  

A down-side is that it makes it hard for scripts to consume the output of
%[ACT]X.  On the other hand, that output is already hard to consume since it
has a bug in the 4.4.0 release, and in any case it is probably better to
specify "%AT %Ap" if that is what you actually want, rather than "%AX".


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?22662>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

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