Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id C07FB431FB6 for ; Sun, 23 Jan 2011 03:47:41 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cLoGVSL-Fzbm for ; Sun, 23 Jan 2011 03:47:40 -0800 (PST) Received: from mail.loccal.net (gw.loccal.net [94.142.235.206]) by olra.theworths.org (Postfix) with ESMTP id C4F9D431FD0 for ; Sun, 23 Jan 2011 03:47:40 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.loccal.net (Postfix) with ESMTP id 4254A1BDAE; Sun, 23 Jan 2011 13:00:56 +0100 (CET) X-Virus-Scanned: amavisd-new at loccal.net Received: from mail.loccal.net ([127.0.0.1]) by localhost (mail.loccal.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id i7W6RjjnJYob; Sun, 23 Jan 2011 13:00:51 +0100 (CET) Received: from steelpick.2x.cz (unknown [10.21.129.4]) by mail.loccal.net (Postfix) with ESMTPS id 6D54A1043A; Sun, 23 Jan 2011 13:00:51 +0100 (CET) Received: from wsh by steelpick.2x.cz with local (Exim 4.72) (envelope-from ) id 1PgyPu-0005hv-6K; Sun, 23 Jan 2011 12:47:34 +0100 From: Michal Sojka To: notmuch@notmuchmail.org Subject: [PATCH 0/4] Versatile date/time parser Date: Sun, 23 Jan 2011 12:47:23 +0100 Message-Id: <1295783247-21900-1-git-send-email-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 1.7.2.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jan 2011 11:47:41 -0000 Hi all, the following patch series brings into notmuch date/time parser stolen from GNU coreutils. It can be applied on top of custom query parser patches from Austin Clements. This is RFC and it not meant for merging. With these patches you can specify the date/time in many ways such as: after:"last monday", after:"2 hours ago", etc. There are some problems, though. 1) The parser is meant for parsing time instant specifications, which not convenient for use with before/after prepositions. For example after:"last Tuesday" should mean Wednesday, Thursday etc. and before:"last Tuesday" should mean Monday, Sunday, etc. Currently, "last Tuesday" means "Tuesday 00:00" and therefore, after:"last Tuesday" also matches mails sent on Tuesday. 2) "yesterday" means "24 hours ago" and not "yesterday midnight" as I would expect. 3) "Tuesday" means the "next Tuesday" instead of the "last Tuesday", which is natural in the context of emails (usually, there are no mails with future dates). I think that all these problems could be fixed in the parser, but maybe some others do not see them as problems or there might be a better parser available for us to use. What do you think? In any way, if anybody wants to try it, the whole patch serie (custom query parser + date parse (without cworth's folder-based search)) is available from my git repository: git pull git://rtime.felk.cvut.cz/notmuch.git date-parser If we decide to use this parser, we might also want to reduce its dependencies a bit. Since it is able to run even on DOS, there are many compatibility functions included. -Michal Michal Sojka (4): Import date/time parser from GNU coreutils Compile the date/time parser into notmuch library Use the time/date parser for after: and before: prefixes Add first date parser tests Makefile.local | 3 + configure | 8 + lib/Makefile.local | 5 +- lib/c-ctype.c | 398 ++++++ lib/c-ctype.h | 297 +++++ lib/config.h | 45 + lib/database.cc | 14 +- lib/getdate.c | 3534 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/getdate.h | 31 + lib/getdate.y | 1609 +++++++++++++++++++++++ lib/gettime.c | 48 + lib/intprops.h | 83 ++ lib/timespec.h | 39 + lib/verify.h | 140 ++ test/Makefile.local | 9 +- test/basic | 2 +- test/date-parser | 37 + test/notmuch-test | 2 +- 18 files changed, 6293 insertions(+), 11 deletions(-) create mode 100644 lib/c-ctype.c create mode 100644 lib/c-ctype.h create mode 100644 lib/config.h create mode 100644 lib/getdate.c create mode 100644 lib/getdate.h create mode 100644 lib/getdate.y create mode 100644 lib/gettime.c create mode 100644 lib/gettime.h create mode 100644 lib/intprops.h create mode 100644 lib/timespec.h create mode 100644 lib/verify.h create mode 100755 test/date-parser -- 1.7.2.3