diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2023-01-01 11:39:38 -0500 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2023-01-01 11:47:49 -0500 |
commit | ac5113640d742c105271a19343d709d5a4f6718c (patch) | |
tree | 2de3918ba5ce1b30da429d28401452cdf285b529 | |
parent | ce6f8bf85b54640b467c59318b7506e4db18bd83 (diff) | |
download | calcurse-ac5113640d742c105271a19343d709d5a4f6718c.tar.gz calcurse-ac5113640d742c105271a19343d709d5a4f6718c.zip |
Fix handling of recurrent open-ended appointments at 00:00
Prior to this commit, a recurrent appointment ending at 00:00 on a given
day was not considered to span the day. This is the correct behavior for
all cases, except appointments without end time (both starting and
ending at midnight on a given day). Handle this edge case explicitly.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r-- | src/recur.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/recur.c b/src/recur.c index 64172ef..d528bf6 100644 --- a/src/recur.c +++ b/src/recur.c @@ -1003,14 +1003,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 |