Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <strong>Time Period Library for .NET</strong> <a href="http://www.codeproject.com/KB/datetime/TimePeriod.aspx" rel="nofollow">http://www.codeproject.com/KB/datetime/TimePeriod.aspx</a> includes the <strong>TimePeriodIntersector</strong> to search for overlapping time periods.</p> <p>The overlaps are calculated with a linear and fast algorithm by counting/sorting all moments on the time line.</p> <p>And the usage of <strong>TimePeriodIntersector</strong> looks like:</p> <pre><code>// ---------------------------------------------------------------------- public void TimePeriodCombinerSample() { TimePeriodCollection periods = new TimePeriodCollection(); periods.Add( new TimeRange( new DateTime( 2011, 3, 01 ), new DateTime( 2011, 3, 10 ) ) ); periods.Add( new TimeRange( new DateTime( 2011, 3, 04 ), new DateTime( 2011, 3, 08 ) ) ); periods.Add( new TimeRange( new DateTime( 2011, 3, 15 ), new DateTime( 2011, 3, 18 ) ) ); periods.Add( new TimeRange( new DateTime( 2011, 3, 18 ), new DateTime( 2011, 3, 22 ) ) ); periods.Add( new TimeRange( new DateTime( 2011, 3, 20 ), new DateTime( 2011, 3, 24 ) ) ); periods.Add( new TimeRange( new DateTime( 2011, 3, 26 ), new DateTime( 2011, 3, 30 ) ) ); TimePeriodCombiner&lt;TimeRange&gt; periodCombiner = new TimePeriodCombiner&lt;TimeRange&gt;(); ITimePeriodCollection combinedPeriods = periodCombiner.CombinePeriods( periods ); foreach ( ITimePeriod combinedPeriod in combinedPeriods ) { Console.WriteLine( "Combined Period: " + combinedPeriod ); } // &gt; Combined Period: 01.03.2011 - 10.03.2011 | 9.00:00 // &gt; Combined Period: 15.03.2011 - 24.03.2011 | 9.00:00 // &gt; Combined Period: 26.03.2011 - 30.03.2011 | 4.00:00 } // TimePeriodCombinerSample </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload