Skip to content

Commit 22280d7

Browse files
peffgitster
authored andcommitted
t0006: check --date=format zone offsets
We already test that "%z" and "%Z" show the right thing, but we don't actually check that the time we display is the correct one. Let's add two new tests: 1. Test that "format:" shows the time in the author's timezone, just like the other time formats. 2. Test that "format-local:" shows time in the local timezone. We don't want to use our normal UTC for this, because its offset is zero (so the result would be "correct" even if the code forgot to apply the offset or applied it in the wrong direction). We'll use the EST5 zone, which is already used elsewhere in the script (and so is assumed to be available everywhere). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c3fbf81 commit 22280d7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

t/t0006-date.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ check_show () {
3131
format=$1
3232
time=$2
3333
expect=$3
34-
test_expect_success $4 "show date ($format:$time)" '
34+
prereqs=$4
35+
zone=$5
36+
test_expect_success $prereqs "show date ($format:$time)" '
3537
echo "$time -> $expect" >expect &&
36-
test-date show:$format "$time" >actual &&
38+
TZ=${zone:-$TZ} test-date show:"$format" "$time" >actual &&
3739
test_cmp expect actual
3840
'
3941
}
@@ -57,6 +59,9 @@ check_show 'format:%Z' "$TIME" ''
5759
check_show 'format:%%z' "$TIME" '%z'
5860
check_show 'format-local:%%z' "$TIME" '%z'
5961

62+
check_show 'format:%Y-%m-%d %H:%M:%S' "$TIME" '2016-06-15 16:13:20'
63+
check_show 'format-local:%Y-%m-%d %H:%M:%S' "$TIME" '2016-06-15 09:13:20' '' EST5
64+
6065
# arbitrary time absurdly far in the future
6166
FUTURE="5758122296 -0400"
6267
check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" LONG_IS_64BIT

0 commit comments

Comments
 (0)