示例#1
0
 /// <summary>
 /// Determines if two DateSpans overlap
 /// </summary>
 /// <param name="Span">The span to compare to</param>
 /// <returns>True if they overlap, false otherwise</returns>
 public bool Overlap(DateSpan Span)
 {
     return ((Start >= Span.Start && Start < Span.End) || (End <= Span.End && End > Span.Start) || (Start <= Span.Start && End >= Span.End));
 }
示例#2
0
 /// <summary>
 /// Returns the intersecting time span between the two values
 /// </summary>
 /// <param name="Span">Span to use</param>
 /// <returns>The intersection of the two time spans</returns>
 public DateSpan Intersection(DateSpan Span)
 {
     if (Span.IsNull())
         return null;
     if (!Overlap(Span))
         return null;
     DateTime Start = Span.Start > this.Start ? Span.Start : this.Start;
     DateTime End = Span.End < this.End ? Span.End : this.End;
     return new DateSpan(Start, End);
 }