]> git.notmuchmail.org Git - notmuch/commitdiff
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)
committerDavid Bremner <david@tethera.net>
Sat, 7 Mar 2015 09:20:33 +0000 (10:20 +0100)
If seconds are not specified in the string to be parsed, they're not
set according to the reference time (in the no rounding case) nor
rounded properly (in the rounding up cases). Fix this.

The bug caused searches such as date:10:30..10:30 to match messages
with date exactly 10:30:00 only, and not in range 10:30:00..10:30:59
(inclusive) as documented.

Note that date searches referring "noon" or "5pm" will still be
interpreted as exact to the second.

parse-time-string/parse-time-string.c
test/T490-parse-time-string.sh

index ccad422b3c8db96462257d3df30660c63f0ee2bb..1cef47d4b0bd85faafe8fdd1cff5ad368d56459c 100644 (file)
@@ -1081,10 +1081,10 @@ parse_time (struct state *state, char sep,
        return set_user_tz (state, state->delim, v1, v2);
     }
 
        return set_user_tz (state, state->delim, v1, v2);
     }
 
-    if (!is_valid_time (v1, v2, v3))
+    if (!is_valid_time (v1, v2, n3 ? v3 : 0))
        return -PARSE_TIME_ERR_INVALIDTIME;
 
        return -PARSE_TIME_ERR_INVALIDTIME;
 
-    return set_abs_time (state, v1, v2, n3 ? v3 : 0);
+    return set_abs_time (state, v1, v2, n3 ? (int) v3 : UNSET);
 }
 
 /* strtoul helper that assigns length. */
 }
 
 /* strtoul helper that assigns length. */
index 9247bdf89543f2c2a9c8d97b2c795087bc348840..6aa9d433bfd40da5562aca16cb0ff79943d502d3 100755 (executable)
@@ -79,7 +79,6 @@ ${TEST_DIRECTORY}/parse-time --ref=${REFERENCE} < INPUT > OUTPUT
 test_expect_equal_file INPUT OUTPUT
 
 test_begin_subtest "Second rounding tests"
 test_expect_equal_file INPUT OUTPUT
 
 test_begin_subtest "Second rounding tests"
-test_subtest_known_broken
 REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011)
 cat <<EOF > INPUT
 9:15         ==> Tue Jan 11 09:15:14 +0000 2011
 REFERENCE=$(_date Tue Jan 11 12:13:14 +0000 2011)
 cat <<EOF > INPUT
 9:15         ==> Tue Jan 11 09:15:14 +0000 2011