aboutsummaryrefslogtreecommitdiffstats
path: root/src/recur.c
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2020-02-10 16:14:26 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2020-04-28 07:32:44 -0400
commitf2918b1700974831fd891b17e7e2126ffa454519 (patch)
tree247a19b185c485a61b66a8931db14ce70cf60bc3 /src/recur.c
parentf3779d59459ee1222d8cc53ce4e4aa009b9c3851 (diff)
downloadcalcurse-f2918b1700974831fd891b17e7e2126ffa454519.tar.gz
calcurse-f2918b1700974831fd891b17e7e2126ffa454519.zip
Support interactive test of recurrence rule extensions
The generic command 'next' is introduced. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src/recur.c')
-rw-r--r--src/recur.c24
1 files changed, 24 insertions, 0 deletions
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;
+}