1 /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 #pragma once 3 4 /* A structure for specifying (possibly repetitive) points in calendar 5 * time, a la cron */ 6 7 #include <stdbool.h> 8 9 #include "time-util.h" 10 #include "util.h" 11 12 typedef struct CalendarComponent { 13 int start; 14 int stop; 15 int repeat; 16 17 struct CalendarComponent *next; 18 } CalendarComponent; 19 20 typedef struct CalendarSpec { 21 int weekdays_bits; 22 bool end_of_month:1; 23 bool utc:1; 24 signed int dst:2; 25 char *timezone; 26 27 CalendarComponent *year; 28 CalendarComponent *month; 29 CalendarComponent *day; 30 31 CalendarComponent *hour; 32 CalendarComponent *minute; 33 CalendarComponent *microsecond; 34 } CalendarSpec; 35 36 CalendarSpec* calendar_spec_free(CalendarSpec *c); 37 38 bool calendar_spec_valid(CalendarSpec *spec); 39 40 int calendar_spec_to_string(const CalendarSpec *spec, char **p); 41 int calendar_spec_from_string(const char *p, CalendarSpec **spec); 42 43 int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next); 44 45 DEFINE_TRIVIAL_CLEANUP_FUNC(CalendarSpec*, calendar_spec_free); 46