aboutsummaryrefslogtreecommitdiffstats
path: root/src/recur.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/recur.c')
-rw-r--r--src/recur.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/recur.c b/src/recur.c
index 72cb40f..10523ad 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -1,7 +1,7 @@
/*
* Calcurse - text-based organizer
*
- * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org>
+ * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -253,8 +253,13 @@ void recur_apoint_free(struct recur_apoint *rapt)
mem_free(rapt->mesg);
if (rapt->note)
mem_free(rapt->note);
- if (rapt->rpt)
+ if (rapt->rpt) {
+ recur_free_exc_list(&rapt->rpt->exc);
+ recur_free_int_list(&rapt->rpt->bywday);
+ recur_free_int_list(&rapt->rpt->bymonth);
+ recur_free_int_list(&rapt->rpt->bymonthday);
mem_free(rapt->rpt);
+ }
recur_free_exc_list(&rapt->exc);
mem_free(rapt);
}
@@ -264,8 +269,13 @@ void recur_event_free(struct recur_event *rev)
mem_free(rev->mesg);
if (rev->note)
mem_free(rev->note);
- if (rev->rpt)
+ if (rev->rpt) {
+ recur_free_exc_list(&rev->rpt->exc);
+ recur_free_int_list(&rev->rpt->bywday);
+ recur_free_int_list(&rev->rpt->bymonth);
+ recur_free_int_list(&rev->rpt->bymonthday);
mem_free(rev->rpt);
+ }
recur_free_exc_list(&rev->exc);
mem_free(rev);
}
@@ -1003,14 +1013,20 @@ static int find_occurrence(time_t start, long dur, struct rpt *rpt, llist_t *exc
if (rpt->until && t >= NEXTDAY(rpt->until))
return 0;
- /* Does it span the given day? */
- if (t + DUR(t) < day)
+ /* Does it span the given day?
+ *
+ * NOTE: An appointment ending at 00:00 is not considered to span the
+ * given day, unless the appointment is an appointment without
+ * specified end time, which is internally treated as appointment with
+ * duration 0.
+ */
+ if (t + DUR(t) >= day || (t == day && dur == 0)) {
+ if (occurrence)
+ *occurrence = t;
+ return 1;
+ } else {
return 0;
-
- if (occurrence)
- *occurrence = t;
-
- return 1;
+ }
}
#undef DUR