title: How to the get the intersections of multiple periods
body: <p>Psudo code:</p>
  
  <pre><code>timelines = [
      (range(&lt;from&gt;, &lt;to&gt;), range(&lt;from&gt;, &lt;to&gt;)),
      (range(&lt;from&gt;, &lt;to&gt;), range(&lt;from&gt;, &lt;to&gt;)),
      (range(&lt;from&gt;, &lt;to&gt;), range(&lt;from&gt;, &lt;to&gt;)),
  ]
  </code></pre>
  
  <p><code>&lt;from&gt;</code> and <code>&lt;to&gt;</code> represent datetime objects</p>
  
  <p>This "picture" shows after "Intersection" the values I need to calculate:</p>
  
  <pre><code>        |----------|    |----------|
                 |------------|   |-------|
          |---------|     |------------|
  
  Intersection   |--|     |---|   |--|
  </code></pre>
  
  <p>How do I calculate these intersections?</p>
  
  <p>I'm coding in python, but answers in any programming language are welcome,
  as I only need to understand the algorithm</p>