diff options
author | René Scharfe <l.s.r@web.de> | 2017-06-15 14:29:53 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-15 14:34:37 -0700 |
commit | c3fbf81a8534cf88ff948d12004eb94929ec1174 (patch) | |
tree | 38baba13d581006b0923be997c27f29d4b4a40fe /strbuf.h | |
parent | b06d3643105c8758ed019125a4399cb7efdcce2c (diff) | |
download | git-c3fbf81a8534cf88ff948d12004eb94929ec1174.tar.gz |
strbuf: let strbuf_addftime handle %z and %Z itself
There is no portable way to pass timezone information to strftime. Add
parameters for timezone offset and name to strbuf_addftime and let it
handle the timezone-related format specifiers %z and %Z internally.
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.
Use an empty string as timezone name in show_date (the only current
caller) for now because we only have the timezone offset in non-local
mode. POSIX allows %Z to resolve to an empty string in case of missing
information.
Helped-by: Ulrich Mueller <ulm@gentoo.org>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
-rw-r--r-- | strbuf.h | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -340,8 +340,14 @@ extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap); /** * Add the time specified by `tm`, as formatted by `strftime`. - */ -extern void strbuf_addftime(struct strbuf *sb, const char *fmt, const struct tm *tm); + * `tz_name` is used to expand %Z internally unless it's NULL. + * `tz_offset` is in decimal hhmm format, e.g. -600 means six hours west + * of Greenwich, and it's used to expand %z internally. However, tokens + * with modifiers (e.g. %Ez) are passed to `strftime`. + */ +extern void strbuf_addftime(struct strbuf *sb, const char *fmt, + const struct tm *tm, int tz_offset, + const char *tz_name); /** * Read a given size of data from a FILE* pointer to the buffer. |