From c0df71fa36b5cacd682bf5748aabd21ca20d7807 Mon Sep 17 00:00:00 2001 From: Doug Christman Date: Tue, 6 Dec 2016 14:41:15 -0500 Subject: calendarspec: always interpret missing seconds as :00 (#4813) "*:*" should be equivalent to "*-*-* *:*:00" (minutely) rather than running every microsecond. Fixes #4804 --- src/basic/calendarspec.c | 8 ++------ src/test/test-calendarspec.c | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c index 8b57de4744..514587d237 100644 --- a/src/basic/calendarspec.c +++ b/src/basic/calendarspec.c @@ -752,12 +752,8 @@ static int parse_calendar_time(const char **p, CalendarSpec *c) { goto fail; /* Already at the end? Then it's hours and minutes, and seconds are 0 */ - if (*t == 0) { - if (m != NULL) - goto null_second; - - goto finish; - } + if (*t == 0) + goto null_second; if (*t != ':') { r = -EINVAL; diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index b3d1160ea7..b8320b081b 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -186,6 +186,9 @@ int main(int argc, char* argv[]) { test_one("Monday *-*-*", "Mon *-*-* 00:00:00"); test_one("*-*-*", "*-*-* 00:00:00"); test_one("*:*:*", "*-*-* *:*:*"); + test_one("*:*", "*-*-* *:*:00"); + test_one("12:*", "*-*-* 12:*:00"); + test_one("*:30", "*-*-* *:30:00"); test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000); test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000); -- cgit v1.2.3-54-g00ecf