[PATCH 4/4] parse-time-string: fix setting and rounding of seconds
authorJani Nikula <jani@nikula.org>
Mon, 2 Mar 2015 17:47:04 +0000 (19:47 +0200)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 21:48:12 +0000 (14:48 -0700)
bc/ff1d044526e69ea2a82b249ea620c0a008abb7 [new file with mode: 0644]

diff --git a/bc/ff1d044526e69ea2a82b249ea620c0a008abb7 b/bc/ff1d044526e69ea2a82b249ea620c0a008abb7
new file mode 100644 (file)
index 0000000..404a909
--- /dev/null
@@ -0,0 +1,113 @@
+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 50AA8429E34\r
+       for <notmuch@notmuchmail.org>; Mon,  2 Mar 2015 10:14:31 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.738\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
+       tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\r
+       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 OPvrJ9lOSwsH for <notmuch@notmuchmail.org>;\r
+       Mon,  2 Mar 2015 10:14:28 -0800 (PST)\r
+Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
+       [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 215A3414B87\r
+       for <notmuch@notmuchmail.org>; Mon,  2 Mar 2015 09:49:34 -0800 (PST)\r
+Received: by widex7 with SMTP id ex7so15943858wid.1\r
+       for <notmuch@notmuchmail.org>; Mon, 02 Mar 2015 09:46:54 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references;\r
+       bh=yX764r3Ad6gCozhZVgLh37yD1RZazCV359veLPiXW0A=;\r
+       b=GyjcNVx2jMzSIfkcaXsjqZHNIHFkq850YLbA1u2BZHJMz0CkidHPyZZQyujUpWMQ8q\r
+       y8Jqx4a0vZDSupQ7Up4lKXQcX88cSWasqSiNpD3VvuW7act+ZUAQHNegnQUtBj3xqgoj\r
+       30c9+z+LfMp1t090hXslHQhEEALhT1FzL6Z6Z7YMP508DhHLiP9Vh5arNgd05o29dk0D\r
+       MeOXeLeoZTjLa5VF5X2DTaU5+/8GC8fFtyhtkn77v8pnfhz/J/6/WrKB79zQu9k2ByOA\r
+       oTuFmKtjpY9rgmH3ame67RMsJdKdPMQ01dlZgdbWZhSIHpNRj4Ut1yjaX6CzRegqE+hZ\r
+       Ec/w==\r
+X-Gm-Message-State:\r
+ ALoCoQl1wjZNtzW4nsM/VnP92uKTFdLRGszlVbIXbj7hyv133Xowzr9/Ra/amFJXYw2bJMLUomcF\r
+X-Received: by 10.194.104.99 with SMTP id gd3mr1156869wjb.114.1425318414038;\r
+       Mon, 02 Mar 2015 09:46:54 -0800 (PST)\r
+Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
+       [188.238.59.76])\r
+       by mx.google.com with ESMTPSA id u6sm17034127wix.12.2015.03.02.09.46.53\r
+       (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+       Mon, 02 Mar 2015 09:46:53 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/4] parse-time-string: fix setting and rounding of seconds\r
+Date: Mon,  2 Mar 2015 19:47:04 +0200\r
+Message-Id: <1425318424-27017-4-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1425318424-27017-1-git-send-email-jani@nikula.org>\r
+References: <1425318424-27017-1-git-send-email-jani@nikula.org>\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: Mon, 02 Mar 2015 18:14:31 -0000\r
+\r
+If seconds are not specified in the string to be parsed, they're not\r
+set according to the reference time (in the no rounding case) nor\r
+rounded properly (in the rounding up cases). Fix this.\r
+\r
+The bug caused searches such as date:10:30..10:30 to match messages\r
+with date exactly 10:30:00 only, and not in range 10:30:00..10:30:59\r
+(inclusive) as documented.\r
+\r
+Note that date searches referring "noon" or "5pm" will still be\r
+interpreted as exact to the second.\r
+---\r
+ parse-time-string/parse-time-string.c | 4 ++--\r
+ test/T490-parse-time-string.sh        | 1 -\r
+ 2 files changed, 2 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c\r
+index ccad422b3c8d..1cef47d4b0bd 100644\r
+--- a/parse-time-string/parse-time-string.c\r
++++ b/parse-time-string/parse-time-string.c\r
+@@ -1081,10 +1081,10 @@ parse_time (struct state *state, char sep,\r
+       return set_user_tz (state, state->delim, v1, v2);\r
+     }\r
\r
+-    if (!is_valid_time (v1, v2, v3))\r
++    if (!is_valid_time (v1, v2, n3 ? v3 : 0))\r
+       return -PARSE_TIME_ERR_INVALIDTIME;\r
\r
+-    return set_abs_time (state, v1, v2, n3 ? v3 : 0);\r
++    return set_abs_time (state, v1, v2, n3 ? (int) v3 : UNSET);\r
+ }\r
\r
+ /* strtoul helper that assigns length. */\r
+diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh\r
+index 9247bdf89543..6aa9d433bfd4 100755\r
+--- a/test/T490-parse-time-string.sh\r
++++ b/test/T490-parse-time-string.sh\r
+@@ -79,7 +79,6 @@ ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT\r
+ test_expect_equal_file INPUT OUTPUT\r
\r
+ test_begin_subtest "Second rounding tests"\r
+-test_subtest_known_broken\r
+ REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011)\r
+ cat <<EOF > INPUT\r
+ 9:15         ==> Tue Jan 11 09:15:14 +0000 2011\r
+-- \r
+2.1.4\r
+\r