summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2017-06-15 14:29:53 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-06-15 14:34:37 -0700
commitc3fbf81a8534cf88ff948d12004eb94929ec1174 (patch)
tree38baba13d581006b0923be997c27f29d4b4a40fe /t
parentGit 2.13 (diff)
downloadtgif-c3fbf81a8534cf88ff948d12004eb94929ec1174.tar.xz
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 't')
-rwxr-xr-xt/t0006-date.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index c0c910867d..fded9dbd68 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -51,6 +51,12 @@ check_show iso-local "$TIME" '2016-06-15 14:13:20 +0000'
check_show raw-local "$TIME" '1466000000 +0000'
check_show unix-local "$TIME" '1466000000'
+check_show 'format:%z' "$TIME" '+0200'
+check_show 'format-local:%z' "$TIME" '+0000'
+check_show 'format:%Z' "$TIME" ''
+check_show 'format:%%z' "$TIME" '%z'
+check_show 'format-local:%%z' "$TIME" '%z'
+
# arbitrary time absurdly far in the future
FUTURE="5758122296 -0400"
check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" LONG_IS_64BIT