git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 11/11] t6300: add tests for "-local" date formats

From
John Keeping <john@keeping.me.uk>
Date
Sep 3, 2015, 21:49 UTC
Message-ID
<5559d4bca517cb1be881e2a2e6ff7aefbd0fee64.1441316394.git.john@keeping.me.uk>
In-Reply-To
<cover.1441316394.git.john@keeping.me.uk>
Signed-off-by: John Keeping <john@keeping.me.uk>
---
Changes since v2:
- "relative-local" and "raw-local" are now allowed
 t/t6300-for-each-ref.sh | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 899251e..03873b0 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -180,6 +180,10 @@ test_expect_success 'Check format "default" formatted date fields output' '
 		"Tue Jul 4 01:18:45 2006 +0200"
 '
 
+test_expect_success 'Check format "default-local" date fields output' '
+	test_date default-local "Mon Jul 3 23:18:43 2006" "Mon Jul 3 23:18:44 2006" "Mon Jul 3 23:18:45 2006"
+'
+
 # Don't know how to do relative check because I can't know when this script
 # is going to be run and can't fake the current time to git, and hence can't
 # provide expected output.  Instead, I'll just make sure that "relative"
@@ -190,10 +194,22 @@ test_expect_success 'Check format "relative" date fields output' '
 	git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual
 '
 
+# We just check that this is the same as "relative" for now.
+test_expect_success 'Check format "relative-local" date fields output' '
+	test_date relative-local \
+		"$(git for-each-ref --format="%(committerdate:relative)" refs/heads)" \
+		"$(git for-each-ref --format="%(authordate:relative)" refs/heads)" \
+		"$(git for-each-ref --format="%(taggerdate:relative)" refs/tags)"
+'
+
 test_expect_success 'Check format "short" date fields output' '
 	test_date short 2006-07-04 2006-07-04 2006-07-04
 '
 
+test_expect_success 'Check format "short-local" date fields output' '
+	test_date short-local 2006-07-03 2006-07-03 2006-07-03
+'
+
 test_expect_success 'Check format "local" date fields output' '
 	test_date local \
 		"Mon Jul 3 23:18:43 2006" \
@@ -208,6 +224,10 @@ test_expect_success 'Check format "iso8601" date fields output' '
 		"2006-07-04 01:18:45 +0200"
 '
 
+test_expect_success 'Check format "iso8601-local" date fields output' '
+	test_date iso8601-local "2006-07-03 23:18:43 +0000" "2006-07-03 23:18:44 +0000" "2006-07-03 23:18:45 +0000"
+'
+
 test_expect_success 'Check format "rfc2822" date fields output' '
 	test_date rfc2822 \
 		"Tue, 4 Jul 2006 01:18:43 +0200" \
@@ -215,10 +235,18 @@ test_expect_success 'Check format "rfc2822" date fields output' '
 		"Tue, 4 Jul 2006 01:18:45 +0200"
 '
 
+test_expect_success 'Check format "rfc2822-local" date fields output' '
+	test_date rfc2822-local "Mon, 3 Jul 2006 23:18:43 +0000" "Mon, 3 Jul 2006 23:18:44 +0000" "Mon, 3 Jul 2006 23:18:45 +0000"
+'
+
 test_expect_success 'Check format "raw" date fields output' '
 	test_date raw "1151968723 +0200" "1151968724 +0200" "1151968725 +0200"
 '
 
+test_expect_success 'Check format "raw-local" date fields output' '
+	test_date raw-local "1151968723 +0000" "1151968724 +0000" "1151968725 +0000"
+'
+
 test_expect_success 'Check format of strftime date fields' '
 	echo "my date is 2006-07-04" >expected &&
 	git for-each-ref \
@@ -227,6 +255,14 @@ test_expect_success 'Check format of strftime date fields' '
 	test_cmp expected actual
 '
 
+test_expect_success 'Check format of strftime-local date fields' '
+	echo "my date is 2006-07-03" >expected &&
+	git for-each-ref \
+	  --format="%(authordate:format-local:my date is %Y-%m-%d)" \
+	  refs/heads >actual &&
+	test_cmp expected actual
+'
+
 test_expect_success 'exercise strftime with odd fields' '
 	echo >expected &&
 	git for-each-ref --format="%(authordate:format:)" refs/heads >actual &&
-- 
2.5.0.466.g9af26fa
Previous: John KeepingNext: Jeff King
Message 54 of 59 in “date: allow any format to display local time”
  1. date: allow any format to display local timeJohn Keeping, Aug 30, 2015
  2. Junio C HamanoAug 31, 2015
  3. Jeff KingAug 31, 2015
  4. Jeff KingAug 31, 2015
  5. Junio C HamanoAug 31, 2015
  6. John KeepingAug 31, 2015
  7. Jeff KingAug 31, 2015
  8. 1/2 fast-import: switch crash-report date to iso8601Jeff King, Aug 31, 2015
  9. 2/2 date: make "local" orthogonal to date formatJeff King, Aug 31, 2015
  10. John KeepingAug 31, 2015
  11. Jeff KingAug 31, 2015
  12. Jeff KingAug 31, 2015
  13. John KeepingSep 1, 2015
  14. 0/6 Make "local" orthogonal to date formatJohn Keeping, Sep 1, 2015
  15. 1/6 fast-import: switch crash-report date to iso8601John Keeping, Sep 1, 2015
  16. 2/6 date: make "local" orthogonal to date formatJohn Keeping, Sep 1, 2015
  17. Junio C HamanoSep 1, 2015
  18. Jeff KingSep 1, 2015
  19. John KeepingSep 1, 2015
  20. Jeff KingSep 1, 2015
  21. Junio C HamanoSep 1, 2015
  22. Junio C HamanoSep 2, 2015
  23. 3/6 t6300: introduce test_date() helperJohn Keeping, Sep 1, 2015
  24. Junio C HamanoSep 1, 2015
  25. Eric SunshineSep 1, 2015
  26. Jeff KingSep 1, 2015
  27. John KeepingSep 1, 2015
  28. Jeff KingSep 1, 2015
  29. 4/6 t6300: make UTC and local dates differentJohn Keeping, Sep 1, 2015
  30. 5/6 t6300: add test for "raw" date formatJohn Keeping, Sep 1, 2015
  31. 6/6 t6300: add tests for "-local" date formatsJohn Keeping, Sep 1, 2015
  32. Jeff KingSep 1, 2015
  33. John KeepingSep 2, 2015
  34. Jeff KingSep 2, 2015
  35. Junio C HamanoSep 2, 2015
  36. John KeepingSep 2, 2015
  37. Junio C HamanoSep 2, 2015
  38. John KeepingSep 2, 2015
  39. Junio C HamanoSep 2, 2015
  40. Jeff KingSep 2, 2015
  41. 00/11 Make "local" orthogonal to date formatJohn Keeping, Sep 3, 2015
  42. 01/11 Documentation/blame-options: don't list date formatsJohn Keeping, Sep 3, 2015
  43. 02/11 Documentation/config: don't list date formatsJohn Keeping, Sep 3, 2015
  44. 03/11 Documentation/git-for-each-ref: don't list date formatsJohn Keeping, Sep 3, 2015
  45. 04/11 Documentation/rev-list: don't list date formatsJohn Keeping, Sep 3, 2015
  46. Junio C HamanoSep 3, 2015
  47. 05/11 fast-import: switch crash-report date to iso8601John Keeping, Sep 3, 2015
  48. 06/11 t6300: introduce test_date() helperJohn Keeping, Sep 3, 2015
  49. 07/11 t6300: add test for "raw" date formatJohn Keeping, Sep 3, 2015
  50. 08/11 date: check for "local" before anything elseJohn Keeping, Sep 3, 2015
  51. Junio C HamanoSep 3, 2015
  52. 09/11 date: make "local" orthogonal to date formatJohn Keeping, Sep 3, 2015
  53. 10/11 t6300: make UTC and local dates differentJohn Keeping, Sep 3, 2015
  54. 11/11 t6300: add tests for "-local" date formatsJohn Keeping, Sep 3, 2015
  55. Jeff KingSep 8, 2015
  56. Junio C HamanoSep 2, 2015
  57. Jeff KingSep 2, 2015
  58. John KeepingSep 2, 2015
  59. Junio C HamanoSep 3, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.