Logo Search packages:      
Sourcecode: libical version File versions

int icaltime_span_overlaps ( icaltime_span s1,
icaltime_span s2 
)

Returns true if the two spans overlap.

Parameters:
s1 1st span to test
s2 2nd span to test
Returns:
boolean value
The result is calculated by testing if the start time of s1 is contained by the s2 span, or if the end time of s1 is contained by the s2 span.

Also returns true if the spans are equal.

Note, this will return false if the spans are adjacent.

Definition at line 1181 of file icaltime.c.

References icaltime_span::end, and icaltime_span::start.

{
  /* s1->start in s2 */
  if (s1->start > s2->start && s1->start < s2->end)
    return 1;

  /* s1->end in s2 */
  if (s1->end > s2->start && s1->end < s2->end)
    return 1;

  /* s2->start in s1 */
  if (s2->start > s1->start && s2->start < s1->end)
    return 1;

  /* s2->end in s1 */
  if (s2->end > s1->start && s2->end < s1->end)
    return 1;

  if (s1->start == s2->start && s1->end == s2->end)
    return 1;
  
  return 0;
}


Generated by  Doxygen 1.6.0   Back to index