Re: [PATCH v3 2/9] parse-time-string: add a date/time parser to notmuch
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 3 Oct 2012 19:02:01 +0000 (21:02 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:49:43 +0000 (09:49 -0800)
af/30ed90b7032e957e2343473200a96f39205e0f [new file with mode: 0644]

diff --git a/af/30ed90b7032e957e2343473200a96f39205e0f b/af/30ed90b7032e957e2343473200a96f39205e0f
new file mode 100644 (file)
index 0000000..a0435d2
--- /dev/null
@@ -0,0 +1,141 @@
+Return-Path: <sojkam1@fel.cvut.cz>\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 8FD7C431FAF\r
+       for <notmuch@notmuchmail.org>; Wed,  3 Oct 2012 12:02:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] 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 QCN6Ngp9vv32 for <notmuch@notmuchmail.org>;\r
+       Wed,  3 Oct 2012 12:02:11 -0700 (PDT)\r
+Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
+       by olra.theworths.org (Postfix) with ESMTP id 750E0431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  3 Oct 2012 12:02:11 -0700 (PDT)\r
+Received: from localhost (unknown [192.168.200.4])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id 6C8573CFE72;\r
+       Wed,  3 Oct 2012 21:02:09 +0200 (CEST)\r
+X-Virus-Scanned: IMAP AMAVIS\r
+Received: from max.feld.cvut.cz ([192.168.200.1])\r
+       by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
+       port 10044)\r
+       with ESMTP id S15GLUU0j2GK; Wed,  3 Oct 2012 21:02:04 +0200 (CEST)\r
+Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
+       by max.feld.cvut.cz (Postfix) with ESMTP id ADCF419F2F35;\r
+       Wed,  3 Oct 2012 21:02:03 +0200 (CEST)\r
+Received: from steelpick.2x.cz (rtime.felk.cvut.cz [147.32.86.92])\r
+       (Authenticated sender: sojkam1)\r
+       by imap.feld.cvut.cz (Postfix) with ESMTPSA id 33B13660904;\r
+       Wed,  3 Oct 2012 21:02:02 +0200 (CEST)\r
+Received: from wsh by steelpick.2x.cz with local (Exim 4.80)\r
+       (envelope-from <sojkam1@fel.cvut.cz>)\r
+       id 1TJUCn-000614-Rb; Wed, 03 Oct 2012 21:02:01 +0200\r
+From: Michal Sojka <sojkam1@fel.cvut.cz>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org,\r
+       David Bremner <david@tethera.net>\r
+Subject: Re: [PATCH v3 2/9] parse-time-string: add a date/time parser to\r
+       notmuch\r
+In-Reply-To: <87391vz8zx.fsf@nikula.org>\r
+References: <cover.1347484177.git.jani@nikula.org>\r
+       <89741ec9a9687fca8b30aa1a4877392d355dd3ce.1347484177.git.jani@nikula.org>\r
+       <8739262u4i.fsf@steelpick.2x.cz> <87391vz8zx.fsf@nikula.org>\r
+User-Agent: Notmuch/0.14+23~g9d68aca (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Wed, 03 Oct 2012 21:02:01 +0200\r
+Message-ID: <87zk43fkgm.fsf@steelpick.2x.cz>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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, 03 Oct 2012 19:02:12 -0000\r
+\r
+On Wed, Oct 03 2012, Jani Nikula wrote:\r
+> On Tue, 25 Sep 2012, Michal Sojka <sojkam1@fel.cvut.cz> wrote:\r
+>> Hello Jani,\r
+>>\r
+>> On Wed, Sep 12 2012, Jani Nikula wrote:\r
+>>> Add a date/time parser to notmuch, to be used for adding date range\r
+>>> query support for notmuch lib later on. Add the parser to a directory\r
+>>> of its own to make it independent of the rest of the notmuch code\r
+>>> base.\r
+>>\r
+>> First of all, thank you very much for pushing this towards mainline.\r
+>> This is definitely one of the features I miss in notmuch most.\r
+>>\r
+>> Some comments below.\r
+>\r
+> Thanks for the comments; sorry about the delay in responding.\r
+\r
+No problem :)\r
+\r
+[...]\r
+\r
+>>> +/**\r
+>>> + * parse_time_string() - user friendly date and time parser\r
+>>> + * @s:            string to parse\r
+>>> + * @t:            pointer to time_t to store parsed time in\r
+>>> + * @now:  pointer to time_t containing reference date/time, or NULL\r
+>>> + * @round:        PARSE_TIME_NO_ROUND, PARSE_TIME_ROUND_DOWN, or\r
+>>> + *                PARSE_TIME_ROUND_UP\r
+>>> + *\r
+>>> + * Parse a date/time string 's' and store the parsed date/time result\r
+>>> + * in 't'.\r
+>>> + *\r
+>>> + * A reference date/time is used for determining the "date/time units"\r
+>>> + * (roughly equivalent to struct tm members) not specified by 's'. If\r
+>>> + * 'now' is non-NULL, it must contain a pointer to a time_t to be used\r
+>>> + * as reference date/time. Otherwise, the current time is used.\r
+>>> + *\r
+>>> + * If 's' does not specify a full date/time, the 'round' parameter\r
+>>> + * specifies if and how the result should be rounded as follows:\r
+>>> + *\r
+>>> + *   PARSE_TIME_NO_ROUND: All date/time units that are not specified\r
+>>> + *   by 's' are set to the corresponding unit derived from the\r
+>>> + *   reference date/time.\r
+>>> + *\r
+>>> + *   PARSE_TIME_ROUND_DOWN: All date/time units that are more accurate\r
+>>> + *   than the most accurate unit specified by 's' are set to the\r
+>>> + *   smallest valid value for that unit. Rest of the unspecified units\r
+>>> + *   are set as in PARSE_TIME_NO_ROUND.\r
+>>> + *\r
+>>> + *   PARSE_TIME_ROUND_UP: All date/time units that are more accurate\r
+>>> + *   than the most accurate unit specified by 's' are set to the\r
+>>> + *   smallest valid value for that unit. The most accurate unit\r
+>>> + *   specified by 's' is incremented by one (and this is rolled over\r
+>>> + *   to the less accurate units as necessary). Rest of the unspecified\r
+>>> + *   units are set as in PARSE_TIME_NO_ROUND.\r
+>>\r
+>> Why you round down and increase the most accurate unit? If I want to see\r
+>> emails that were send yesterday, I do not want to see any email that was\r
+>> sent the first second of today. (OK, I know that this is slightly easier\r
+>> to implement)\r
+>\r
+> It's easy to agree that yesterday's messages should not include messages\r
+> from the first second of today. It's not even too difficult to implement\r
+> that. But doing that in this API would feel like rounding 0.6 up and\r
+> getting 0.9999... as a result.\r
+>\r
+> I'll look at adding a separate rounding mode to keep the API generic\r
+> while better support the sole user of the API.\r
+\r
+I agree that the operation I want here should not be called rounding.\r
+Maybe, you can use a term from set theory: supremum or prehaps maximum\r
+(seconds are countable).\r
+\r
+Cheers,\r
+-Michal\r