#include <stdlib.h>
#include <string.h>
+#include "alloc-util.h"
#include "calendarspec.h"
+#include "fileio.h"
+#include "string-util.h"
#define BITS_WEEKDAYS 127
return -EINVAL;
}
-static int parse_time(const char **p, CalendarSpec *c) {
+static int parse_calendar_time(const char **p, CalendarSpec *c) {
CalendarComponent *h = NULL, *m = NULL, *s = NULL;
const char *t;
int r;
int calendar_spec_from_string(const char *p, CalendarSpec **spec) {
CalendarSpec *c;
int r;
+ const char *utc;
assert(p);
assert(spec);
if (!c)
return -ENOMEM;
- c->utc = endswith_no_case(p, "UTC");
- if (c->utc)
- p = strndupa(p, strlen(p) - strlen(" UTC"));
+ utc = endswith_no_case(p, " UTC");
+ if (utc) {
+ c->utc = true;
+ p = strndupa(p, utc - p);
+ }
if (strcaseeq(p, "minutely")) {
r = const_chain(0, &c->second);
if (r < 0)
goto fail;
- r = parse_time(&p, c);
+ r = parse_calendar_time(&p, c);
if (r < 0)
goto fail;