From 776ef240755fc86222dfa412e2411791576fb90e Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Sat, 11 Apr 2015 10:37:54 +0200
Subject: Do not mark slice of end time busy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In weekly view, when computing busy slices, do not fill a slot that is
only hit by the end time of an appointment.

Suggested-by: HÃ¥kan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/day.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

(limited to 'src')

diff --git a/src/day.c b/src/day.c
index 75719a6..0391548 100644
--- a/src/day.c
+++ b/src/day.c
@@ -582,8 +582,15 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
 		else
 			end = DAYINSEC - 1;
 
-		if (!fill_slices
-		    (slices, slicesno, SLICENUM(start), SLICENUM(end))) {
+		/*
+		 * If an item ends on 12:00, we do not want the 12:00 slot to
+		 * be marked busy.
+		 */
+		if (end > start)
+			end--;
+
+		if (!fill_slices(slices, slicesno, SLICENUM(start),
+					SLICENUM(end))) {
 			LLIST_TS_UNLOCK(&recur_alist_p);
 			return 0;
 		}
@@ -603,8 +610,15 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
 		if (apt->start + apt->dur >= t + DAYINSEC)
 			end = DAYINSEC - 1;
 
-		if (!fill_slices
-		    (slices, slicesno, SLICENUM(start), SLICENUM(end))) {
+		/*
+		 * If an item ends on 12:00, we do not want the 12:00 slot to
+		 * be marked busy.
+		 */
+		if (end > start)
+			end--;
+
+		if (!fill_slices(slices, slicesno, SLICENUM(start),
+					SLICENUM(end))) {
 			LLIST_TS_UNLOCK(&alist_p);
 			return 0;
 		}
-- 
cgit v1.2.3-70-g09d2