From 5e94b28d4a62cd590f173e0358cb3272073e4585 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 27 Feb 2016 13:34:33 -0500 Subject: Fix -daystart to not round 0 upwards. --- parse.c | 9 ++++++--- tests.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/parse.c b/parse.c index 0db2572..4e487dc 100644 --- a/parse.c +++ b/parse.c @@ -494,10 +494,13 @@ static struct expr *parse_daystart(struct parser_state *state) { return NULL; } - tm.tm_sec = 0; - tm.tm_min = 0; + if (tm.tm_hour || tm.tm_min || tm.tm_sec || state->now.tv_nsec) { + ++tm.tm_mday; + } tm.tm_hour = 0; - ++tm.tm_mday; + tm.tm_min = 0; + tm.tm_sec = 0; + time_t time = mktime(&tm); if (time == -1) { perror("mktime()"); diff --git a/tests.sh b/tests.sh index baaac3e..77ba586 100755 --- a/tests.sh +++ b/tests.sh @@ -255,7 +255,15 @@ function test_0046() { find_diff -L "$basic" -group "$(id -g)" } -for i in {1..46}; do +function test_0047() { + find_diff -L "$basic" -daystart -mtime 0 +} + +function test_0048() { + find_diff -L "$basic" -daystart -daystart -mtime 0 +} + +for i in {1..48}; do test="test_$(printf '%04d' $i)" "$test" "$dir" status=$? -- cgit v1.2.3