Re: [PATCH 4/4] parse-time-string: fix setting and rounding of seconds
[notmuch-archives.git] / 85 / 85adefb81133f7a787c9342b7ec090b5e8212d
1 Return-Path: <tomi.ollila@iki.fi>\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 0872D431FAF\r
6         for <notmuch@notmuchmail.org>; Mon,  2 Mar 2015 12:06:59 -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: 2.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 21kVHJyYQ9Uj for <notmuch@notmuchmail.org>;\r
16         Mon,  2 Mar 2015 12:06:55 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id AD8AC431FAE\r
19         for <notmuch@notmuchmail.org>; Mon,  2 Mar 2015 12:06:55 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id B86521000E7;\r
22         Mon,  2 Mar 2015 22:03:55 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
25 Subject: Re: [PATCH 4/4] parse-time-string: fix setting and rounding of\r
26  seconds\r
27 In-Reply-To: <1425318424-27017-4-git-send-email-jani@nikula.org>\r
28 References: <1425318424-27017-1-git-send-email-jani@nikula.org>\r
29         <1425318424-27017-4-git-send-email-jani@nikula.org>\r
30 User-Agent: Notmuch/0.19+53~gb45d2f9 (http://notmuchmail.org) Emacs/24.3.1\r
31         (x86_64-unknown-linux-gnu)\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
33         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
34         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
35 Date: Mon, 02 Mar 2015 22:03:55 +0200\r
36 Message-ID: <m2bnkbnp3o.fsf@guru.guru-group.fi>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Mon, 02 Mar 2015 20:06:59 -0000\r
52 \r
53 On Mon, Mar 02 2015, Jani Nikula <jani@nikula.org> wrote:\r
54 \r
55 > If seconds are not specified in the string to be parsed, they're not\r
56 > set according to the reference time (in the no rounding case) nor\r
57 > rounded properly (in the rounding up cases). Fix this.\r
58 >\r
59 > The bug caused searches such as date:10:30..10:30 to match messages\r
60 > with date exactly 10:30:00 only, and not in range 10:30:00..10:30:59\r
61 > (inclusive) as documented.\r
62 >\r
63 > Note that date searches referring "noon" or "5pm" will still be\r
64 > interpreted as exact to the second.\r
65 \r
66 Although I don't fully understands how these changes do the trick (and I\r
67 only looked the context) the changes *look* good, and presumably fix\r
68 the problem in question (I could check intermediate output but i am just\r
69 lazy).\r
70 \r
71 Tests pass and I don't see why anything could get broken by this so +1\r
72 \r
73 Tomi\r
74 \r
75 \r
76 > ---\r
77 >  parse-time-string/parse-time-string.c | 4 ++--\r
78 >  test/T490-parse-time-string.sh        | 1 -\r
79 >  2 files changed, 2 insertions(+), 3 deletions(-)\r
80 >\r
81 > diff --git a/parse-time-string/parse-time-string.c b/parse-time-string/parse-time-string.c\r
82 > index ccad422b3c8d..1cef47d4b0bd 100644\r
83 > --- a/parse-time-string/parse-time-string.c\r
84 > +++ b/parse-time-string/parse-time-string.c\r
85 > @@ -1081,10 +1081,10 @@ parse_time (struct state *state, char sep,\r
86 >       return set_user_tz (state, state->delim, v1, v2);\r
87 >      }\r
88 >  \r
89 > -    if (!is_valid_time (v1, v2, v3))\r
90 > +    if (!is_valid_time (v1, v2, n3 ? v3 : 0))\r
91 >       return -PARSE_TIME_ERR_INVALIDTIME;\r
92 >  \r
93 > -    return set_abs_time (state, v1, v2, n3 ? v3 : 0);\r
94 > +    return set_abs_time (state, v1, v2, n3 ? (int) v3 : UNSET);\r
95 >  }\r
96 >  \r
97 >  /* strtoul helper that assigns length. */\r
98 > diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh\r
99 > index 9247bdf89543..6aa9d433bfd4 100755\r
100 > --- a/test/T490-parse-time-string.sh\r
101 > +++ b/test/T490-parse-time-string.sh\r
102 > @@ -79,7 +79,6 @@ ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT\r
103 >  test_expect_equal_file INPUT OUTPUT\r
104 >  \r
105 >  test_begin_subtest "Second rounding tests"\r
106 > -test_subtest_known_broken\r
107 >  REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011)\r
108 >  cat <<EOF > INPUT\r
109 >  9:15         ==> Tue Jan 11 09:15:14 +0000 2011\r
110 > -- \r
111 > 2.1.4\r
112 >\r
113 > _______________________________________________\r
114 > notmuch mailing list\r
115 > notmuch@notmuchmail.org\r
116 > http://notmuchmail.org/mailman/listinfo/notmuch\r