Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh/stat: output atime/mtime/ctime with nanoseconds



On 19 Jun 2018, at 09:18, Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
>Under Linux, the stat utility from GNU Coreutils outputs
>atime/mtime/ctime with nanoseconds.
>
>IMHO, zsh should do the same.

The GNU tools that support nanoseconds in time strings tend to use Gnulib's
nstrftime(), which provides their %N extension to the standard strftime(3)
stuff.

zsh has a similar function, ztrftime(), which zsh/stat uses. The first problem
is that the module doesn't pass the file's sub-second time information to the
function, and the second problem is that, even if it did, ztrftime() only
supports microsecond granularity. I think it would be very easy to change both
of those things, but there may be some portability issues with getting the
nanosecond information itself.

(Also, not all file systems even record times to the nanosecond — HFS+ only has
whole-second granularity for example — but that's another thing.)

If nobody has any objections i might look into this later; there've been a few
times i wanted '%9.' myself.

dana



Messages sorted by: Reverse Date, Date, Thread, Author