path: root/date.c
diff options
authorRené Scharfe <>2017-06-15 12:29:53 (GMT)
committerJunio C Hamano <>2017-06-15 21:34:37 (GMT)
commitc3fbf81a8534cf88ff948d12004eb94929ec1174 (patch)
tree38baba13d581006b0923be997c27f29d4b4a40fe /date.c
parentb06d3643105c8758ed019125a4399cb7efdcce2c (diff)
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 <> Helped-by: Jeff King <> Signed-off-by: Rene Scharfe <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'date.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/date.c b/date.c
index a996331..6eccbd8 100644
--- a/date.c
+++ b/date.c
@@ -233,7 +233,7 @@ const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
month_names[tm->tm_mon], tm->tm_year + 1900,
tm->tm_hour, tm->tm_min, tm->tm_sec, tz);
else if (mode->type == DATE_STRFTIME)
- strbuf_addftime(&timebuf, mode->strftime_fmt, tm);
+ strbuf_addftime(&timebuf, mode->strftime_fmt, tm, tz, "");
strbuf_addf(&timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d",