diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-06-22 14:15:25 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-22 14:15:25 -0700 |
commit | 9eafe86d58a2d2b30e8b33f6697519fc7f104443 (patch) | |
tree | 511646eac969baa9feef1b949696a5b6a66e94d8 /t | |
parent | Merge branch 'sd/t3200-branch-m-test' (diff) | |
parent | date: use localtime() for "-local" time formats (diff) | |
download | tgif-9eafe86d58a2d2b30e8b33f6697519fc7f104443.tar.xz |
Merge branch 'rs/strbuf-addftime-zZ'
As there is no portable way to pass timezone information to
strftime, some output format from "git log" and friends are
impossible to produce. Teach our own strbuf_addftime to replace %z
and %Z with caller-supplied values to help working around this.
* rs/strbuf-addftime-zZ:
date: use localtime() for "-local" time formats
t0006: check --date=format zone offsets
strbuf: let strbuf_addftime handle %z and %Z itself
Diffstat (limited to 't')
-rwxr-xr-x | t/t0006-date.sh | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/t/t0006-date.sh b/t/t0006-date.sh index 42d4ea61ef..7ac9466d50 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -31,9 +31,11 @@ check_show () { format=$1 time=$2 expect=$3 - test_expect_success $4 "show date ($format:$time)" ' + prereqs=$4 + zone=$5 + test_expect_success $prereqs "show date ($format:$time)" ' echo "$time -> $expect" >expect && - test-date show:$format "$time" >actual && + TZ=${zone:-$TZ} test-date show:"$format" "$time" >actual && test_cmp expect actual ' } @@ -51,6 +53,16 @@ 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-local:%Z' "$TIME" 'UTC' +check_show 'format:%%z' "$TIME" '%z' +check_show 'format-local:%%z' "$TIME" '%z' + +check_show 'format:%Y-%m-%d %H:%M:%S' "$TIME" '2016-06-15 16:13:20' +check_show 'format-local:%Y-%m-%d %H:%M:%S' "$TIME" '2016-06-15 09:13:20' '' EST5 + # arbitrary time absurdly far in the future FUTURE="5758122296 -0400" check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" TIME_IS_64BIT,TIME_T_IS_64BIT |