summaryrefslogtreecommitdiffstats
path: root/src/day.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/day.c')
-rw-r--r--src/day.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/day.c b/src/day.c
index bd21023..2bd4a31 100644
--- a/src/day.c
+++ b/src/day.c
@@ -507,13 +507,26 @@ void day_popup_item(struct day_item *day)
}
/*
- * Need to know if there is an item for the current selected day inside
- * calendar. This is used to put the correct colors inside calendar panel.
+ * Check whether there is an item on a given day.
+ *
+ * Returns 2 if the selected day contains a regular event or appointment.
+ * Returns 1 if the selected day does not contain a regular event or
+ * appointment but an occurrence of a recurrent item. Returns 0 otherwise.
*/
int day_check_if_item(struct date day)
{
const time_t t = date2sec(day, 0, 0);
+ if (LLIST_FIND_FIRST(&eventlist, (time_t *)&t, event_inday))
+ return 2;
+
+ LLIST_TS_LOCK(&alist_p);
+ if (LLIST_TS_FIND_FIRST(&alist_p, (time_t *)&t, apoint_inday)) {
+ LLIST_TS_UNLOCK(&alist_p);
+ return 2;
+ }
+ LLIST_TS_UNLOCK(&alist_p);
+
if (LLIST_FIND_FIRST(&recur_elist, (time_t *)&t, recur_event_inday))
return 1;
@@ -525,16 +538,6 @@ int day_check_if_item(struct date day)
}
LLIST_TS_UNLOCK(&recur_alist_p);
- if (LLIST_FIND_FIRST(&eventlist, (time_t *)&t, event_inday))
- return 1;
-
- LLIST_TS_LOCK(&alist_p);
- if (LLIST_TS_FIND_FIRST(&alist_p, (time_t *)&t, apoint_inday)) {
- LLIST_TS_UNLOCK(&alist_p);
- return 1;
- }
- LLIST_TS_UNLOCK(&alist_p);
-
return 0;
}