Re: [PATCH v2] strbuf: let strbuf_addftime handle %z and %Z itself
- From
- Ulrich Mueller <ulm@gentoo.org>
- Date
- Jun 15, 2017, 11:27 UTC
- Message-ID
- <22850.28477.715057.441985@a1i15.kph.uni-mainz.de>
- In-Reply-To
- <d578d104-79c6-6c07-db4d-3e4ccb0c0dd9@web.de>
>>>>> 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.)
> 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.
Ulrich