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

[PATCH 2/2] Allow testing of _relative family of time formatting and parsing functions

From
Alex Riesen <raa.lkml@gmail.com>
Date
Aug 28, 2009, 21:05 UTC
Message-ID
<20090828210511.GB11867@blimp.localdomain>
In-Reply-To
<20090828210404.GA11867@blimp.localdomain>
To complement the testability of approxidate.
---
 test-date.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/test-date.c b/test-date.c
index 62e8f23..dcc7973 100644
--- a/test-date.c
+++ b/test-date.c
@@ -4,6 +4,17 @@ int main(int argc, char **argv)
 {
 	int i;
 
+	struct tm tm;
+	struct timeval when = {0, 0};
+	tm.tm_sec  = 0;
+	tm.tm_min  = 0;
+	tm.tm_hour = 12;
+	tm.tm_mday = 1;
+	tm.tm_mon  = 0  /* January */;
+	tm.tm_year = 90 /* 1990 */ ;
+	tm.tm_isdst = -1;
+	when.tv_sec = mktime(&tm);
+
 	for (i = 1; i < argc; i++) {
 		char result[100];
 		time_t t;
@@ -15,6 +26,12 @@ int main(int argc, char **argv)
 
 		t = approxidate(argv[i]);
 		printf("%s -> %s\n", argv[i], ctime(&t));
+
+		t = approxidate_relative(argv[i], &when);
+		printf("relative: %s -> %s\n", argv[i], ctime(&t));
+
+		printf("relative: %s, out of %s\n",
+		       show_date_relative(t, 0, &when), ctime(&t));
 	}
 	return 0;
 }
-- 
1.6.4.1.263.g468a
Previous: Alex RiesenNext: Jeff King
Message 2 of 4 in “Add date formatting and parsing functions relative to a given time”
  1. 1/2 Add date formatting and parsing functions relative to a given timeAlex Riesen, Aug 28, 2009
  2. 2/2 Allow testing of _relative family of time formatting and parsing functionsAlex Riesen, Aug 28, 2009
  3. Jeff KingAug 30, 2009
  4. Alex RiesenAug 30, 2009

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.