HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

src/shared/calendarspec.h

1,396 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: d45aaa8a371d29564df4fdff1047c87ac44e0a5a

Lines 1–48 of 48

/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
 
/* A structure for specifying (possibly repetitive) points in calendar
 * time, a la cron */
 
#include "forward.h"
 
typedef struct CalendarComponent {
        int start;
        int stop;
        int repeat;
 
        struct CalendarComponent *next;
} CalendarComponent;
 
typedef struct CalendarSpec {
        int weekdays_bits;
        bool end_of_month:1;
        bool utc:1;
        signed int dst:2;
        char *timezone;
 
        CalendarComponent *year;
        CalendarComponent *month;
        CalendarComponent *day;
 
        CalendarComponent *hour;
        CalendarComponent *minute;
        CalendarComponent *microsecond;
} CalendarSpec;
 
CalendarSpec* calendar_spec_free(CalendarSpec *c);
 
bool calendar_spec_valid(CalendarSpec *spec);
 
int calendar_spec_to_string(const CalendarSpec *spec, char **ret);
int calendar_spec_from_string_full(const char *p, CalendarSpec **ret, bool warn_on_weekday_mismatch);
 
static inline int calendar_spec_from_string(const char *p, CalendarSpec **ret) {
        return calendar_spec_from_string_full(p, ret, /* warn_on_weekday_mismatch= */ false);
}
 
int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next);
bool calendar_spec_weekday_conflicts(const CalendarSpec *spec, int *ret_actual_wday);
 
DEFINE_TRIVIAL_CLEANUP_FUNC(CalendarSpec*, calendar_spec_free);