]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
663996b3 MS |
2 | #pragma once |
3 | ||
663996b3 MS |
4 | /* A structure for specifying (possibly repetitive) points in calendar |
5 | * time, a la cron */ | |
6 | ||
7 | #include <stdbool.h> | |
4c89c718 MP |
8 | |
9 | #include "time-util.h" | |
663996b3 MS |
10 | #include "util.h" |
11 | ||
12 | typedef struct CalendarComponent { | |
2897b343 MP |
13 | int start; |
14 | int stop; | |
663996b3 MS |
15 | int repeat; |
16 | ||
17 | struct CalendarComponent *next; | |
18 | } CalendarComponent; | |
19 | ||
20 | typedef struct CalendarSpec { | |
21 | int weekdays_bits; | |
2897b343 | 22 | bool end_of_month; |
db2df898 | 23 | bool utc; |
8a584da2 | 24 | int dst; |
f5e65279 | 25 | char *timezone; |
663996b3 MS |
26 | |
27 | CalendarComponent *year; | |
28 | CalendarComponent *month; | |
29 | CalendarComponent *day; | |
30 | ||
31 | CalendarComponent *hour; | |
32 | CalendarComponent *minute; | |
4c89c718 | 33 | CalendarComponent *microsecond; |
663996b3 MS |
34 | } CalendarSpec; |
35 | ||
52ad194e | 36 | CalendarSpec* calendar_spec_free(CalendarSpec *c); |
663996b3 MS |
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); | |
52ad194e MB |
45 | |
46 | DEFINE_TRIVIAL_CLEANUP_FUNC(CalendarSpec*, calendar_spec_free); |