(zsh.info.gz) The zsh/datetime Module
Info Catalog
(zsh.info.gz) The zsh/curses Module
(zsh.info.gz) Zsh Modules
(zsh.info.gz) The zsh/deltochar Module
22.10 The zsh/datetime Module
=============================
The zsh/datetime module makes available one builtin command:
strftime [ -s SCALAR ] FORMAT EPOCHTIME
strftime -r [ -q ] [ -s SCALAR ] FORMAT TIMESTRING
Output the date denoted by EPOCHTIME in the FORMAT specified.
With the option -r (reverse), use the format FORMAT to parse the
input string TIMESTRING and output the number of seconds since the
epoch at which the time occurred. If no timezone is parsed, the
current timezone is used; other parameters are set to zero if not
present. If TIMESTRING does not match FORMAT the command returns
status 1; it will additionally print an error message unless the
option -q (quiet) is given. If TIMESTRING matches FORMAT but not
all characters in TIMESTRING were used, the conversion succeeds;
however, a warning is issued unless the option -q is given. The
matching is implemented by the system function strptime; see man
page strptime(3). This means that zsh format extensions are not
available, however for reverse lookup they are not required. If
the function is not implemented, the command returns status 2 and
(unless -q is given) prints a message.
If -s SCALAR is given, assign the date string (or epoch time in
seconds if -r is given) to SCALAR instead of printing it.
The zsh/datetime module makes available several parameters; all are
readonly:
EPOCHREALTIME
A floating point value representing the number of seconds since the
epoch. The notional accuracy is to nanoseconds if the
clock_gettime call is available and to microseconds otherwise, but
in practice the range of double precision floating point and shell
scheduling latencies may be significant effects.
EPOCHSECONDS
An integer value representing the number of seconds since the
epoch.
epochtime
An array value containing the number of seconds since the epoch in
the first element and the remainder of the time since the epoch in
nanoseconds in the second element. To ensure the two elements are
consistent the array should be copied or otherwise referenced as a
single substitution before the values are used. The following
idiom may be used:
for secs nsecs in $epochtime; do
...
done
Info Catalog
(zsh.info.gz) The zsh/curses Module
(zsh.info.gz) Zsh Modules
(zsh.info.gz) The zsh/deltochar Module
automatically generated by
info2html