--- /dev/null
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id B0B7D431FC4\r
+ for <notmuch@notmuchmail.org>; Wed, 12 Sep 2012 14:27:52 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id DLk4SSzXCWvf for <notmuch@notmuchmail.org>;\r
+ Wed, 12 Sep 2012 14:27:50 -0700 (PDT)\r
+Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com\r
+ [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 94C22431FBF\r
+ for <notmuch@notmuchmail.org>; Wed, 12 Sep 2012 14:27:43 -0700 (PDT)\r
+Received: by mail-lb0-f181.google.com with SMTP id gk1so1587473lbb.26\r
+ for <notmuch@notmuchmail.org>; Wed, 12 Sep 2012 14:27:43 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references\r
+ :in-reply-to:references:mime-version:content-type\r
+ :content-transfer-encoding:x-gm-message-state;\r
+ bh=LYU0qbNmIrV2qbjDj72xbhvjtMSldh8P1re9D4XWQrc=;\r
+ b=nEnRHuf38ltBl4fcyahUgVAC44LkcJtv1FRfvtUZ4ptCmTBWdgCSekWFCKye65h8XT\r
+ y1gWoZDYUUpWJij3RLh0JCi8kPurc6ifH9H59sPWXTfw7iRYMe/XVJP49VdGfXgffdaw\r
+ FbDkVe8Nnl8LDZZCESUMCHW6k7N5+rP6o6aAJca4WC+dTZjdi+ZGtsn+4vM8dRYvBE4j\r
+ oZgBeV23CE1ykLzzQC5iLlt35VqNR6OPi4Ofk5nT0hMMLPWL0zBeLuKMuNpnT+siPVcF\r
+ PL5+l9QMaO4f39653cGvkYQwcXQ/igol2yZRYroyo39M8eUOa01MTfJ5q+ALUBHUCkf0\r
+ N5SA==\r
+Received: by 10.112.83.129 with SMTP id q1mr131010lby.89.1347485263162;\r
+ Wed, 12 Sep 2012 14:27:43 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi.\r
+ [80.223.81.27])\r
+ by mx.google.com with ESMTPS id y4sm5532727lbg.5.2012.09.12.14.27.40\r
+ (version=SSLv3 cipher=OTHER); Wed, 12 Sep 2012 14:27:42 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org,\r
+ David Bremner <david@tethera.net>\r
+Subject:\r
+ [PATCH v3 3/9] test: add new test tool parse-time for date/time parser\r
+Date: Thu, 13 Sep 2012 00:27:20 +0300\r
+Message-Id:\r
+ <a5998ce294d32f66f4ce9572d50710d117f6bd8b.1347484177.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <cover.1347484177.git.jani@nikula.org>\r
+References: <cover.1347484177.git.jani@nikula.org>\r
+In-Reply-To: <cover.1347484177.git.jani@nikula.org>\r
+References: <cover.1347484177.git.jani@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-Gm-Message-State:\r
+ ALoCoQkb2UJWgQw2f4wWzZspsdG+IfjuxG0qUuILiwInLtjgL/Mvm7b7gfL51ogaPwrUu6wQmVtD\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 12 Sep 2012 21:27:53 -0000\r
+\r
+Add a smoke testing tool to support testing the date/time parser\r
+module directly and independent of the rest of notmuch.\r
+---\r
+ test/Makefile.local | 7 ++-\r
+ test/basic | 2 +-\r
+ test/parse-time.c | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 3 files changed, 152 insertions(+), 2 deletions(-)\r
+ create mode 100644 test/parse-time.c\r
+\r
+diff --git a/test/Makefile.local b/test/Makefile.local\r
+index 45df4c7..9ae130a 100644\r
+--- a/test/Makefile.local\r
++++ b/test/Makefile.local\r
+@@ -19,9 +19,13 @@ $(dir)/smtp-dummy: $(smtp_dummy_modules)\r
+ $(dir)/symbol-test: $(dir)/symbol-test.o\r
+ $(call quiet,CXX) $^ -o $@ -Llib -lnotmuch $(XAPIAN_LDFLAGS)\r
+ \r
++$(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o\r
++ $(call quiet,CC) $^ -o $@\r
++\r
+ .PHONY: test check\r
+ \r
+-test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test\r
++test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test \\r
++ $(dir)/parse-time\r
+ \r
+ test: all test-binaries\r
+ @${dir}/notmuch-test $(OPTIONS)\r
+@@ -32,4 +36,5 @@ SRCS := $(SRCS) $(smtp_dummy_srcs)\r
+ CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \\r
+ $(dir)/symbol-test $(dir)/symbol-test.o \\r
+ $(dir)/arg-test $(dir)/arg-test.o \\r
++ $(dir)/parse-time $(dir)/parse-time.o \\r
+ $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*\r
+diff --git a/test/basic b/test/basic\r
+index 3b635c8..c47197c 100755\r
+--- a/test/basic\r
++++ b/test/basic\r
+@@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
+ eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)\r
+ tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
+ available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 | \\r
+- sed -r -e "s,.*/,," -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d" | \\r
++ sed -r -e "s,.*/,," -e "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d" | \\r
+ sort)\r
+ test_expect_equal "$tests_in_suite" "$available"\r
+ \r
+diff --git a/test/parse-time.c b/test/parse-time.c\r
+new file mode 100644\r
+index 0000000..b4de76b\r
+--- /dev/null\r
++++ b/test/parse-time.c\r
+@@ -0,0 +1,145 @@\r
++/*\r
++ * parse time string - user friendly date and time parser\r
++ * Copyright © 2012 Jani Nikula\r
++ *\r
++ * This program is free software: you can redistribute it and/or modify\r
++ * it under the terms of the GNU General Public License as published by\r
++ * the Free Software Foundation, either version 2 of the License, or\r
++ * (at your option) any later version.\r
++ *\r
++ * This program is distributed in the hope that it will be useful,\r
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
++ * GNU General Public License for more details.\r
++ *\r
++ * You should have received a copy of the GNU General Public License\r
++ * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
++ *\r
++ * Author: Jani Nikula <jani@nikula.org>\r
++ */\r
++\r
++#include <getopt.h>\r
++#include <stdio.h>\r
++#include <stdlib.h>\r
++#include <string.h>\r
++\r
++#include "parse-time-string.h"\r
++\r
++/*\r
++ * concat argv[start]...argv[end - 1], separating them by a single\r
++ * space, to a malloced string\r
++ */\r
++static char *\r
++concat_args (int start, int end, char *argv[])\r
++{\r
++ int i;\r
++ size_t len = 1;\r
++ char *p;\r
++\r
++ for (i = start; i < end; i++)\r
++ len += strlen (argv[i]) + 1;\r
++\r
++ p = malloc (len);\r
++ if (!p)\r
++ return NULL;\r
++\r
++ *p = 0;\r
++\r
++ for (i = start; i < end; i++) {\r
++ if (i != start)\r
++ strcat (p, " ");\r
++ strcat (p, argv[i]);\r
++ }\r
++\r
++ return p;\r
++}\r
++\r
++#define DEFAULT_FORMAT "%a %b %d %T %z %Y"\r
++\r
++static void\r
++usage (const char *name)\r
++{\r
++ printf ("Usage: %s [options ...] <date/time>\n\n", name);\r
++ printf (\r
++ "Parse <date/time> and display it in given format.\n\n"\r
++ " -f, --format=FMT output format, FMT according to strftime(3)\n"\r
++ " (default: \"%s\")\n"\r
++ " -n, --now=N use N seconds since epoch as now (default: now)\n"\r
++ " -u, --up round result up (default: no rounding)\n"\r
++ " -d, --down round result down (default: no rounding)\n"\r
++ " -h, --help print this help\n",\r
++ DEFAULT_FORMAT);\r
++}\r
++\r
++int\r
++main (int argc, char *argv[])\r
++{\r
++ int r;\r
++ struct tm tm;\r
++ time_t result;\r
++ time_t now;\r
++ time_t *nowp = NULL;\r
++ char *argstr;\r
++ int round = PARSE_TIME_NO_ROUND;\r
++ char buf[1024];\r
++ const char *format = DEFAULT_FORMAT;\r
++ struct option options[] = {\r
++ { "help", no_argument, NULL, 'h' },\r
++ { "up", no_argument, NULL, 'u' },\r
++ { "down", no_argument, NULL, 'd' },\r
++ { "format", required_argument, NULL, 'f' },\r
++ { "now", required_argument, NULL, 'n' },\r
++ { NULL, 0, NULL, 0 },\r
++ };\r
++\r
++ for (;;) {\r
++ int c;\r
++\r
++ c = getopt_long (argc, argv, "hudf:n:", options, NULL);\r
++ if (c == -1)\r
++ break;\r
++\r
++ switch (c) {\r
++ case 'f':\r
++ /* output format */\r
++ format = optarg;\r
++ break;\r
++ case 'u':\r
++ round = PARSE_TIME_ROUND_UP;\r
++ break;\r
++ case 'd':\r
++ round = PARSE_TIME_ROUND_DOWN;\r
++ break;\r
++ case 'n':\r
++ /* specify now in seconds since epoch */\r
++ now = (time_t) strtol (optarg, NULL, 10);\r
++ if (now >= (time_t) 0)\r
++ nowp = &now;\r
++ break;\r
++ case 'h':\r
++ case '?':\r
++ default:\r
++ usage (argv[0]);\r
++ return 1;\r
++ }\r
++ }\r
++\r
++ argstr = concat_args (optind, argc, argv);\r
++ if (!argstr)\r
++ return 1;\r
++\r
++ r = parse_time_string (argstr, &result, nowp, round);\r
++\r
++ free (argstr);\r
++\r
++ if (r)\r
++ return 1;\r
++\r
++ if (!localtime_r (&result, &tm))\r
++ return 1;\r
++\r
++ strftime (buf, sizeof (buf), format, &tm);\r
++ printf ("%s\n", buf);\r
++\r
++ return 0;\r
++}\r
+-- \r
+1.7.9.5\r
+\r