]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/calendarspec.h
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / src / shared / calendarspec.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
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;
23 bool utc;
24 int dst;
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 int calendar_spec_normalize(CalendarSpec *spec);
39 bool calendar_spec_valid(CalendarSpec *spec);
40
41 int calendar_spec_to_string(const CalendarSpec *spec, char **p);
42 int calendar_spec_from_string(const char *p, CalendarSpec **spec);
43
44 int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next);
45
46 DEFINE_TRIVIAL_CLEANUP_FUNC(CalendarSpec*, calendar_spec_free);