ical_ctdl_is_overlap.c: cleaned it up
[citadel.git] / citadel / server / modules / calendar / ical_ctdl_is_overlap.c
index d980c554b53645faf385fa786a3908f0eb50dbe0..30a0b166d5eabfdcfb9e87bab8ee38bab3e789dd 100644 (file)
@@ -26,27 +26,22 @@ int ical_ctdl_is_overlap(
        }
        else {
                if (t1end.is_date && icaltime_compare(t1start, t1end)) {
-
-                       // The end date is non-inclusive so adjust it by one
-                       // day because our test is inclusive, note that a day is
-                       // not too much because we are talking about all day events.
-                       //
-                       // If start = end we assume that nevertheless the whole day is meant.
-
+                       // The end date is non-inclusive so adjust it by one day because our test is inclusive.
+                       // Note that a day is not too much because we are talking about all day events.
+                       // If start==end we assume that it means one day.
                        icaltime_adjust(&t1end, -1, 0, 0, 0);   
                }
        }
 
 #ifdef DEBUG_ICAL_OVERLAP
-       syslog(LOG_DEBUG, "Comparing t1start=%s,t1end=%s to t2start=%s,t2end=%s",
-               icaltime_as_ical_string_r(t1start),
-               icaltime_as_ical_string_r(t1end),
-               icaltime_as_ical_string_r(t2start),
-               icaltime_as_ical_string_r(t2end)
+       syslog(LOG_DEBUG, "Comparing t1start=%s(%s),t1end=%s(%s) to t2start=%s(%s),t2end=%s(%s)",
+               icaltime_as_ical_string_r(t1start),     icaltime_get_tzid(t1start),
+               icaltime_as_ical_string_r(t1end),       icaltime_get_tzid(t1end),
+               icaltime_as_ical_string_r(t2start),     icaltime_get_tzid(t2start),
+               icaltime_as_ical_string_r(t2end),       icaltime_get_tzid(t2end)
        );
 #endif
 
-
        if (icaltime_is_null_time(t2end)) {
                memcpy(&t2end, &t2start, sizeof(struct icaltimetype));
        }
@@ -69,14 +64,13 @@ int ical_ctdl_is_overlap(
        }
 
        // Now check for overlaps using date *and* time.
+       // We could probably implement this in terms of icaltime_span_overlaps() but this does the same thing.
 
        // If event 1 ends before event 2 starts, there is no match.
        if (icaltime_compare(t1end, t2start) <= 0) return(0);
-       // syslog(LOG_DEBUG, "calendar: first passed");
 
        // If event 2 ends before event 1 starts, there is no match.
        if (icaltime_compare(t2end, t1start) <= 0) return(0);
-       // syslog(LOG_DEBUG, "calendar: second passed");
 
        // Otherwise, there is an overlap, so yes we have a match.
        return(1);