Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / b0 / df08a6ccc4bae6a3e15123bd8ff46b42417b2d
1 Return-Path: <sojkam1@fel.cvut.cz>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 69CFA42D280\r
6         for <notmuch@notmuchmail.org>; Sun, 23 Jan 2011 03:47:41 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id jxZCRljl50yP for <notmuch@notmuchmail.org>;\r
16         Sun, 23 Jan 2011 03:47:40 -0800 (PST)\r
17 Received: from mail.loccal.net (gw.loccal.net [94.142.235.206])\r
18         by olra.theworths.org (Postfix) with ESMTP id 635D4431FB6\r
19         for <notmuch@notmuchmail.org>; Sun, 23 Jan 2011 03:47:40 -0800 (PST)\r
20 Received: from localhost (localhost [127.0.0.1])\r
21         by mail.loccal.net (Postfix) with ESMTP id 7AC481BDB2;\r
22         Sun, 23 Jan 2011 13:00:55 +0100 (CET)\r
23 X-Virus-Scanned: amavisd-new at loccal.net\r
24 Received: from mail.loccal.net ([127.0.0.1])\r
25         by localhost (mail.loccal.net [127.0.0.1]) (amavisd-new, port 10024)\r
26         with LMTP id pUJ0f8wsru5H; Sun, 23 Jan 2011 13:00:51 +0100 (CET)\r
27 Received: from steelpick.2x.cz (unknown [10.21.129.4])\r
28         by mail.loccal.net (Postfix) with ESMTPS id 824031BDAE;\r
29         Sun, 23 Jan 2011 13:00:51 +0100 (CET)\r
30 Received: from wsh by steelpick.2x.cz with local (Exim 4.72)\r
31         (envelope-from <sojkam1@fel.cvut.cz>)\r
32         id 1PgyPu-0005i5-Lh; Sun, 23 Jan 2011 12:47:34 +0100\r
33 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH 3/4] Use the time/date parser for after: and before: prefixes\r
36 Date: Sun, 23 Jan 2011 12:47:26 +0100\r
37 Message-Id: <1295783247-21900-4-git-send-email-sojkam1@fel.cvut.cz>\r
38 X-Mailer: git-send-email 1.7.2.3\r
39 In-Reply-To: <1295783247-21900-1-git-send-email-sojkam1@fel.cvut.cz>\r
40 References: <1295783247-21900-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.13\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sun, 23 Jan 2011 11:47:41 -0000\r
54 \r
55 This allows to have queries like:\r
56   after:10am\r
57   after:"10:00 GMT"\r
58   after:"now -2 hours"\r
59   after:"2 hours ago"\r
60   after:yesterday\r
61   after:"last month"\r
62 ---\r
63  lib/database.cc |   14 ++++++++------\r
64  1 files changed, 8 insertions(+), 6 deletions(-)\r
65 \r
66 diff --git a/lib/database.cc b/lib/database.cc\r
67 index cb02220..615b408 100644\r
68 --- a/lib/database.cc\r
69 +++ b/lib/database.cc\r
70 @@ -19,6 +19,7 @@\r
71   */\r
72  \r
73  #include "database-private.h"\r
74 +#include "getdate.h"\r
75  \r
76  #include <iostream>\r
77  \r
78 @@ -643,16 +644,17 @@ transform_date (_notmuch_token_t *root, void *opaque)\r
79         int before = (strcmp (root->text, "before") == 0);\r
80         if (after || before) {\r
81             _notmuch_token_t *tok = root->left;\r
82 -           struct tm t;\r
83 +           bool ok;\r
84 +           struct timespec result, now;\r
85             time_t time_value;\r
86 -           char *end, *serialzed;\r
87 +           char *serialzed;\r
88  \r
89             /* Parse the date */\r
90             assert (tok && tok->type == TOK_LIT);\r
91 -           memset(&t, 0, sizeof(t));\r
92 -           end = strptime (tok->text, "%Y/%m/%d", &t);\r
93 -           time_value = mktime(&t);\r
94 -           if (!end || *end || time_value == -1) {\r
95 +           clock_gettime (CLOCK_REALTIME, &now);\r
96 +           ok = get_date (&result, tok->text, &now);\r
97 +           time_value = result.tv_sec;\r
98 +           if (!ok || time_value == -1) {\r
99                 char *msg = talloc_asprintf (root, "Invalid date \"%s\"",\r
100                                              tok->text);\r
101                 return _notmuch_token_create_term (root, TOK_ERROR, msg);\r
102 -- \r
103 1.7.2.3\r
104 \r