Am 15.06.2017 um 13:27 schrieb Ulrich Mueller:
On Thu, 15 Jun 2017, René Scharfe wrote:
Callers can opt out for %Z by passing NULL as timezone name. %z is
always handled internally -- this helps on Windows, where strftime would
expand it to a timezone name (same as %Z), in violation of POSIX.
Modifiers are not handled, e.g. %Ez is still passed to strftime.
POSIX would also allow other things, like a field width:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/strftime.html
$ date '+%8z'
+0000200
(But I believe that's not very useful, and supporting it might require
duplicating much of strftime's code.)
Windows doesn't support that (unsurprisingly), but it accepts %#z,
which does the same as %z. Let's wait for someone to request support
for modifiers and just document the behavior for now.
Changes from v1:
- Always handle %z internally.
Minor nitpick: Shouldn't the comment in strbuf.h be updated to reflect
that change?
+ * Add the time specified by `tm`, as formatted by `strftime`. `tz_offset`
+ * and `tz_name` are used to expand %z and %Z internally, unless `tz_name`
+ * is NULL. `tz_offset` is in decimal hhmm format, e.g. -600 means six
+ * hours west of Greenwich.
Yes, it should. Thanks for paying attention! :)
René