From 7924315bfb8ae707b2b510b808377c79355ba6a2 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 28 Aug 2017 06:56:12 +0200 Subject: Fix support for punctual appointments at 00:00 When checking whether an appointment belongs to a given day in apoint_inday(), the return value was 0 if the end time of the appointment matched 00:00 on that day (because we do not want to include appointments starting on the day before and lasting until midnight). However, this means that punctual appointments at 00:00 were not included in any day. Fix the apoint_inday() logic to take this into consideration. Fixes GitHub issue #39. Signed-off-by: Lukas Fleischer --- src/apoint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/apoint.c') diff --git a/src/apoint.c b/src/apoint.c index d5d9dc3..a1c4934 100644 --- a/src/apoint.c +++ b/src/apoint.c @@ -119,8 +119,9 @@ struct apoint *apoint_new(char *mesg, char *note, long start, long dur, unsigned apoint_inday(struct apoint *i, long *start) { - return (date_cmp_day(i->start, *start) <= 0 && - date_cmp_day(i->start + i->dur - 1, *start) >= 0); + return (date_cmp_day(i->start, *start) == 0 || + (date_cmp_day(i->start, *start) < 0 && + date_cmp_day(i->start + i->dur - 1, *start) >= 0)); } void apoint_sec2str(struct apoint *o, long day, char *start, char *end) -- cgit v1.2.3-54-g00ecf