From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Builtin strftime and TZ assignments
Date: Sat, 21 Feb 2015 14:04:06 -0800 [thread overview]
Message-ID: <150221140406.ZM23169@torch.brasslantern.com> (raw)
In-Reply-To: <150221124546.ZM8579@torch.brasslantern.com>
On Feb 21, 12:45pm, Bart Schaefer wrote:
}
} } The next question is whether the strftime builtin should implicitly
} } perform "local -x TZ" to make Kurtis' example do the expected thing.
Regardless, the documentation is wrong about timezone handling. Here
is an update.
diff --git a/Doc/Zsh/mod_datetime.yo b/Doc/Zsh/mod_datetime.yo
index 6190676..27bc781 100644
--- a/Doc/Zsh/mod_datetime.yo
+++ b/Doc/Zsh/mod_datetime.yo
@@ -8,25 +8,46 @@ findex(strftime)
cindex(date string, printing)
xitem(tt(strftime) [ tt(-s) var(scalar) ] var(format) var(epochtime) )
item(tt(strftime) tt(-r) [ tt(-q) ] [ tt(-s) var(scalar) ] var(format) var(timestring) )(
-Output the date denoted by var(epochtime) in the var(format)
-specified.
+Output the date denoted by var(epochtime) in the var(format) specified.
+See manref(strftime)(3) for details. The zsh extensions described in
+ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion)) are also available.
-With the option tt(-r) (reverse), use the format var(format) to parse the
-input string var(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
-var(timestring) does not match var(format) the command returns status 1; it
-will additionally print an error message unless the option tt(-q) (quiet)
-is given. If var(timestring) matches var(format) but not all characters in
-var(timestring) were used, the conversion succeeds; however, a warning is
-issued unless the option tt(-q) is given. The matching is implemented by
-the system function tt(strptime); see manref(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 tt(-q) is given) prints a message.
+startitem()
+item(tt(-q))(
+Run quietly; suppress printing of all error messages described below.
+Errors for invalid var(epochtime) values are always printed.
+)
+item(tt(-r))(
+With the option tt(-r) (reverse), use var(format) to parse the input
+string var(timestring) and output the number of seconds since the epoch at
+which the time occurred. The parsing is implemented by the system
+function tt(strptime); see manref(strptime)(3). This means that zsh
+format extensions are not available, but for reverse lookup they are not
+required.
+
+In most implementations of tt(strftime) any timezone in the
+var(timestring) is ignored and the local timezone declared by the tt(TZ)
+environment variable is used; other parameters are set to zero if not
+present.
+
+If var(timestring) does not match var(format) the command returns status 1
+and prints an error message. If var(timestring) matches var(format) but
+not all characters in var(timestring) were used, the conversion succeeds
+but also prints an error message.
+
+If either of the system functions tt(strptime) or tt(mktime) is not
+available, status 2 is returned and an error message is printed.
+)
+item(tt(-s) var(scalar))(
+Assign the date string (or epoch time in seconds if tt(-r) is given) to
+var(scalar) instead of printing it.
+)
+enditem()
-If tt(-s) var(scalar) is given, assign the date string (or epoch time
-in seconds if tt(-r) is given) to var(scalar) instead of printing it.
+Note that depending on the system's declared integral time type,
+tt(strftime) may produce incorrect results for epoch times greater than
+2147483647 which corresponds to 2038-01-19 03:14:07 +0000.
)
enditem()
--
Barton E. Schaefer
next prev parent reply other threads:[~2015-02-21 22:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CADjGqHvaOkB-T_qGHDvt9=8TzSGiR8-FptXCX8VNFyfPkmJN-g@mail.gmail.com>
[not found] ` <CABx2=D9e8KPMd9fxL5UY5BoVOdnNyMx-d2tR3v_4Gmd7V5m7DQ@mail.gmail.com>
[not found] ` <150221102305.ZM26540@torch.brasslantern.com>
2015-02-21 20:45 ` Bart Schaefer
2015-02-21 22:04 ` Bart Schaefer [this message]
2015-02-21 22:27 ` Peter Stephenson
2015-02-21 22:54 ` Bart Schaefer
2015-02-21 23:16 ` Peter Stephenson
2015-02-22 0:39 ` Bart Schaefer
2015-02-22 3:53 ` Bart Schaefer
2015-02-22 13:18 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=150221140406.ZM23169@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).