title: How to chop a continuous date range list into a list of financial year in C#?
body: <p>Example: given a continuous list of date range</p>
  
  <blockquote>
    <p>List[0] = from 2001 Jan 01 to 2001 Aug 14 </p>
    
    <p>List[1] = from 2001 Aug 15 to 2002 Jul 10</p>
  </blockquote>
  
  <p>Let’s assume that a financial year is from 1st of July to 30th of June (of next year) so the output should be</p>
  
  <blockquote>
    <p>AnotherList[0] = from 2000 Jul 01 to 2001 Jun 30</p>
  
  <pre><code>  period: 2001 Jan 01 to 2001 Jun 30
  </code></pre>
    
    <p>AnotherList[1] = from 2001 July 01 to 2002 Jun 30</p>
  
  <pre><code>  period: 2001 Jul 01 to 2001 Aug 14
    period: 2001 Aug 15 to 2002 Jun 30
  </code></pre>
    
    <p>AnotherList[2] = from 2002 July 01 to 2003 Jun 30</p>
  
  <pre><code>  period: 2002 Jul 01 to 2002 Jul 10
  </code></pre>
  </blockquote>
  
  <p>Again it's very easy to work out by hand but my method contains close to 100 lines of code with the combination of if else, for each and while loops which I think it's ugly. I am trying to simplify the algorithm so that it's easier to maintain and debug. Thanks in advance.</p>