Skip to content

Commit

Permalink
stat: do not provide variable precision time stamps
Browse files Browse the repository at this point in the history
* src/stat.c: Don't include fstimeprec.c.
(out_epoch_sec): Don't call fstimeprec.
* NEWS: Update description.
* doc/coreutils.texi: Likewise.
  • Loading branch information
Jim Meyering committed Nov 13, 2010
1 parent 6568b17 commit 4a8e9bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
5 changes: 3 additions & 2 deletions NEWS
Expand Up @@ -24,8 +24,9 @@ GNU coreutils NEWS -*- outline -*-
stat's %X, %Y, and %Z directives once again print only the integer
part of seconds since the epoch. This reverts a change from
coreutils-8.6, that was deemed unnecessarily disruptive. To obtain
a full resolution time stamp for %X, use %.X; if you want (say) just
3 fractional digits, use %.3X. Likewise for %Y and %Z.
a nanosecond-precision floating point time stamp for %X use %.X;
if you want (say) just 3 fractional digits, use %.3X. Likewise
for %Y and %Z.

stat's new %W format directive would print floating point seconds.
However, with the above change to %X, %Y and %Z, we've made %W work
Expand Down
10 changes: 5 additions & 5 deletions doc/coreutils.texi
Expand Up @@ -10718,10 +10718,10 @@ The valid @var{format} directives for files with @option{--format} and

The @samp{%W}, @samp{%X}, @samp{%Y}, and @samp{%Z} formats accept a
precision preceded by a period to specify the number of digits to
print after the decimal point. For example, @samp{%.9X} outputs the
last access time to nanosecond precision. If a period is given but no
precision, @command{stat} uses the estimated precision of the file
system. When discarding excess precision, time stamps are truncated
print after the decimal point. For example, @samp{%.3X} outputs the
last access time to millisecond precision. If a period is given but no
precision, @command{stat} uses 9 digits, so @samp{%.X} is equivalent to
@samp{%.9X} When discarding excess precision, time stamps are truncated
toward minus infinity.

@example
Expand All @@ -10737,7 +10737,7 @@ precision:
$ stat -c '[%.3Y]' /usr
[1288929712.114]
$ stat -c '[%.Y]' /usr
[1288929712.114951]
[1288929712.114951834]
@end example

The mount point printed by @samp{%m} is similar to that output
Expand Down
2 changes: 1 addition & 1 deletion gnulib
Submodule gnulib updated from 4baf5c to 6383a3
6 changes: 1 addition & 5 deletions src/stat.c
Expand Up @@ -63,7 +63,6 @@
#include "file-type.h"
#include "filemode.h"
#include "fs.h"
#include "fstimeprec.h"
#include "getopt.h"
#include "mountlist.h"
#include "quote.h"
Expand Down Expand Up @@ -557,10 +556,7 @@ out_epoch_sec (char *pformat, size_t prefix_len, struct stat const *statbuf,
}
else
{
static struct fstimeprec *tab;
if (! tab)
tab = fstimeprec_alloc ();
precision = fstimeprec (tab, statbuf);
precision = 9;
}

if (precision && ISDIGIT (dot[-1]))
Expand Down

0 comments on commit 4a8e9bf

Please sign in to comment.