git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Nicolas Pitre <nico@cam.org>,
	David Reiss <dreiss@facebook.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/2] Allow testing of _relative family of time formatting and parsing functions
Date: Fri, 28 Aug 2009 23:05:11 +0200	[thread overview]
Message-ID: <20090828210511.GB11867@blimp.localdomain> (raw)
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

  reply	other threads:[~2009-08-28 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-28 21:04 [PATCH 1/2] Add date formatting and parsing functions relative to a given time Alex Riesen
2009-08-28 21:05 ` Alex Riesen [this message]
2009-08-30  7:36 ` Jeff King
2009-08-30  7:51   ` Alex Riesen
  -- strict thread matches above, loose matches on Subject: below --
2009-08-28 15:02 [PATCH] Round-down years in "years+months" relative date view Jeff King
2009-08-28 17:28 ` Nicolas Pitre
2009-08-28 19:03   ` Alex Riesen
2009-08-28 19:15     ` Jeff King
2009-08-28 19:20       ` Alex Riesen
2009-08-28 19:33         ` Alex Riesen
2009-08-28 20:52           ` [PATCH] Allow testing of _relative family of time formatting and parsing functions Alex Riesen
2009-08-29 21:46             ` Junio C Hamano
2009-08-30  7:25               ` Alex Riesen
2009-08-30  9:13                 ` [PATCH 1/2] Add date formatting and parsing functions relative to a given time Alex Riesen
2009-08-30  9:15                   ` [PATCH 2/2] Allow testing of _relative family of time formatting and parsing functions Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090828210511.GB11867@blimp.localdomain \
    --to=raa.lkml@gmail.com \
    --cc=dreiss@facebook.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nico@cam.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).