From 3215e35c405278491f55fb486d349f132e93f516 Mon Sep 17 00:00:00 2001 From: Douglas Christman Date: Thu, 24 Nov 2016 14:34:17 -0500 Subject: [PATCH] calendarspec: make specifications with seconds wildcard reversible "*:*:*" is now formatted as "*:*:*" instead of "*:*:00/1" --- src/basic/calendarspec.c | 8 +++++++- src/test/test-calendarspec.c | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/basic/calendarspec.c b/src/basic/calendarspec.c index 1555230..1de04fe 100644 --- a/src/basic/calendarspec.c +++ b/src/basic/calendarspec.c @@ -286,6 +286,7 @@ static void format_chain(FILE *f, int space, const CalendarComponent *c, bool us } int calendar_spec_to_string(const CalendarSpec *c, char **p) { + CalendarComponent *cc; char *buf = NULL; size_t sz = 0; FILE *f; @@ -313,7 +314,12 @@ int calendar_spec_to_string(const CalendarSpec *c, char **p) { fputc(':', f); format_chain(f, 2, c->minute, false); fputc(':', f); - format_chain(f, 2, c->microsecond, true); + + cc = c->microsecond; + if (cc && !cc->value && cc->repeat == USEC_PER_SEC && !cc->next) + fputc('*', f); + else + format_chain(f, 2, c->microsecond, true); if (c->utc) fputs(" UTC", f); diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c index 873a491..d4bb4a1 100644 --- a/src/test/test-calendarspec.c +++ b/src/test/test-calendarspec.c @@ -183,6 +183,7 @@ int main(int argc, char* argv[]) { test_one("Monday", "Mon *-*-* 00:00:00"); test_one("Monday *-*-*", "Mon *-*-* 00:00:00"); test_one("*-*-*", "*-*-* 00:00:00"); + test_one("*:*:*", "*-*-* *:*:*"); test_next("2016-03-27 03:17:00", "", 12345, 1459048620000000); test_next("2016-03-27 03:17:00", "CET", 12345, 1459041420000000); -- 2.7.4