Date Range Calculation .Any Suggestions?
<p>I need to calculate some Date Ranges.</p>

<p>I have three Date Ranges:</p>

<ol>
<li>25 July 11 - 10 Oct 11</li>
<li>05 Aug  11 - 05 Oct 11</li>
<li><p>20 Aug  11 - 08 Nov 11</p>

<p>I need to create a new membership for all the valid periods that can be before and after</p>

<p>What is a good way to do this? </p>

<p>Code Example</p>

<pre><code>       public enum MembershipType
       {
          Gym=1,
          Magazine=2,
          Hotel=3
       }
       class Program
       {
          static void Main()
          {
             // During  1st Aug 2011 and 20th Oct 2011 Membership payment must be stopped
             var stopPaymentStartDate  =  new DateTime(2011,08,1);
             var stopPaymentEndDate    =  new DateTime(2011,10,20);


             var gymMembership = new Membership{MembershipType=MembershipType.Gym, StartDate = new DateTime(2011, 07, 25), EndDate = new DateTime(2011, 10, 10)};
             var magazineMembership = new Membership{MembershipType = MembershipType.Magazine,StartDate = new DateTime(2011, 08, 5),EndDate = new DateTime(2011, 10, 5)};
             var hotelMembership = new Membership{MembershipType = MembershipType.Hotel,StartDate = new DateTime(2011, 08, 20),EndDate = new DateTime(2011, 11, 8)};

             //How Can I get the wanted result below:
             //???

             //Wanted List of result as follows:
             var gymMembershipResult = new Result{MembershipType = MembershipType.Gym,StartDate = new DateTime(2011, 10, 10),EndDate = new DateTime(2011, 10, 20)};
             var magazineMembershipResultOne = new Result { MembershipType = MembershipType.Magazine, StartDate = new DateTime(2011, 08, 01), EndDate = new DateTime(2011, 08,05) };
             var magazineMembershipResultTwo = new Result { MembershipType = MembershipType.Magazine, StartDate = new DateTime(2011, 10, 05), EndDate = new DateTime(2011, 10, 20) };
             var hotelMembershipResult = new Result { MembershipType = MembershipType.Hotel, StartDate = new DateTime(2011, 08, 01), EndDate = new DateTime(2011, 08, 20) };

          }
       }
       public class Result
       {
          public DateTime StartDate { get; set; }
          public DateTime EndDate { get; set; }
          public MembershipType MembershipType { get; set; }
       }
       public class Membership
       {
          public DateTime StartDate { get; set; }
          public DateTime EndDate { get; set; }
          public MembershipType MembershipType { get; set; }
       }
    }
</code></pre></li>
</ol>
