From f2918b1700974831fd891b17e7e2126ffa454519 Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Mon, 10 Feb 2020 16:14:26 +0100 Subject: Support interactive test of recurrence rule extensions The generic command 'next' is introduced. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/recur.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/recur.c') diff --git a/src/recur.c b/src/recur.c index e0a6b05..997fb15 100644 --- a/src/recur.c +++ b/src/recur.c @@ -1772,3 +1772,27 @@ void recur_apoint_paste_item(struct recur_apoint *rapt, time_t date) if (notify_bar()) notify_check_repeated(rapt); } + +/* + * Finds the next occurrence of a recurrent item and returns it in the provided + * buffer. Useful for test of a repeated item. + */ +int recur_next_occurrence(time_t s, long d, struct rpt *r, llist_t *e, + time_t occur, time_t *next) +{ + int ret = 0; + + if (r->until && r->until <= occur) + return ret; + + while (!r->until || occur < r->until) { + occur = NEXTDAY(occur); + if (!check_sec(&occur)) + break; + if (recur_item_find_occurrence(s, d, r, e, occur, next)) { + ret = 1; + break; + } + } + return ret; +} -- cgit v1.2.3-54-g00ecf