summaryrefslogtreecommitdiff
path: root/t/t0006-date.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-02-06 22:05:24 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-02-06 22:05:24 -0800
commitecbe1beb8e41664ac00581234a449c4487600e1d (patch)
treed53750776f3409aa3b3646c2b4027ac487e6c70a /t/t0006-date.sh
parentMerge branch 'jk/autocrlf-overrides-eol-doc' (diff)
parentAdd `human` date format tests. (diff)
downloadtgif-ecbe1beb8e41664ac00581234a449c4487600e1d.tar.xz
Merge branch 'lt/date-human'
A new date format "--date=human" that morphs its output depending on how far the time is from the current time has been introduced. "--date=auto" can be used to use this new format when the output is going to the pager or to the terminal and otherwise the default format. * lt/date-human: Add `human` date format tests. Add `human` format to test-tool Add 'human' date format documentation Replace the proposed 'auto' mode with 'auto:' Add 'human' date format
Diffstat (limited to 't/t0006-date.sh')
-rwxr-xr-xt/t0006-date.sh22
1 files changed, 20 insertions, 2 deletions
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index ffb2975e48..d9fcc829a9 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -4,10 +4,10 @@ test_description='test date parsing and printing'
. ./test-lib.sh
# arbitrary reference time: 2009-08-30 19:20:00
-TEST_DATE_NOW=1251660000; export TEST_DATE_NOW
+GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
check_relative() {
- t=$(($TEST_DATE_NOW - $1))
+ t=$(($GIT_TEST_DATE_NOW - $1))
echo "$t -> $2" >expect
test_expect_${3:-success} "relative date ($2)" "
test-tool date relative $t >actual &&
@@ -128,4 +128,22 @@ check_approxidate '6AM, June 7, 2009' '2009-06-07 06:00:00'
check_approxidate '2008-12-01' '2008-12-01 19:20:00'
check_approxidate '2009-12-01' '2009-12-01 19:20:00'
+check_date_format_human() {
+ t=$(($GIT_TEST_DATE_NOW - $1))
+ echo "$t -> $2" >expect
+ test_expect_success "human date $t" '
+ test-tool date human $t >actual &&
+ test_i18ncmp expect actual
+'
+}
+
+check_date_format_human 18000 "5 hours ago" # 5 hours ago
+check_date_format_human 432000 "Tue Aug 25 19:20" # 5 days ago
+check_date_format_human 1728000 "Mon Aug 10 19:20" # 3 weeks ago
+check_date_format_human 13000000 "Thu Apr 2 08:13" # 5 months ago
+check_date_format_human 31449600 "Aug 31 2008" # 12 months ago
+check_date_format_human 37500000 "Jun 22 2008" # 1 year, 2 months ago
+check_date_format_human 55188000 "Dec 1 2007" # 1 year, 9 months ago
+check_date_format_human 630000000 "Sep 13 1989" # 20 years ago
+
test_done