summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Christman <DouglasChristman@gmail.com>2016-11-24 11:50:06 -0500
committerDouglas Christman <DouglasChristman@gmail.com>2016-11-24 18:22:08 -0500
commit408a51e15614ca0c6cd80558adb20efe448d16d8 (patch)
tree124a98ab99eeb4ecac3b86cebc23190af8762f63 /src
parent28d329571aaeebda140122167cd48755637400b2 (diff)
calendarspec: always interpret a missing time as 00:00:00
"*-*-*" is now equivalent to "*-*-* 00:00:00" (daily) rather than "*-*-* *:*:*" (every second).
Diffstat (limited to 'src')
-rw-r--r--src/basic/calendarspec.c11
-rw-r--r--src/test/test-calendarspec.c4
2 files changed, 7 insertions, 8 deletions
diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c
index 359bb16cae..db11e55390 100644
--- a/src/basic/calendarspec.c
+++ b/src/basic/calendarspec.c
@@ -699,14 +699,9 @@ static int parse_calendar_time(const char **p, CalendarSpec *c) {
t = *p;
- if (*t == 0) {
- /* If no time is specified at all, but a date of some
- * kind, then this means 00:00:00 */
- if (c->day || c->weekdays_bits > 0)
- goto null_hour;
-
- goto finish;
- }
+ /* If no time is specified at all, then this means 00:00:00 */
+ if (*t == 0)
+ goto null_hour;
r = parse_chain(&t, false, &h);
if (r < 0)
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
index 76f5819bb9..7357c522e0 100644
--- a/src/test/test-calendarspec.c
+++ b/src/test/test-calendarspec.c
@@ -179,6 +179,9 @@ int main(int argc, char* argv[]) {
test_one("*-*~1 Utc", "*-*~01 00:00:00 UTC");
test_one("*-*~05,3 ", "*-*~03,05 00:00:00");
test_one("*-*~* 00:00:00", "*-*-* 00:00:00");
+ test_one("Monday", "Mon *-*-* 00:00:00");
+ test_one("Monday *-*-*", "Mon *-*-* 00:00:00");
+ test_one("*-*-*", "*-*-* 00:00:00");
test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000);
test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000);
@@ -199,6 +202,7 @@ int main(int argc, char* argv[]) {
test_next("Mon 2017-05~07/1 UTC", "", 12345, 1496016000000000);
assert_se(calendar_spec_from_string("test", &c) < 0);
+ assert_se(calendar_spec_from_string(" ", &c) < 0);
assert_se(calendar_spec_from_string("", &c) < 0);
assert_se(calendar_spec_from_string("7", &c) < 0);
assert_se(calendar_spec_from_string("121212:1:2", &c) < 0);