title: Datetime: Split a time segment in Days, Hours and Minutes
body: <p>I need to write a function that takes two timestamps and segment the time range in Days, Hours and Seconds in that order. To walk through an example, lets say the input to our function is</p>
  
  <p>val start = 08-01-14 12:30:00
  val end = 08-04-14 12:30:00</p>
  
  <p>our function will return </p>
  
  <pre><code> min -&gt;  (08-01-14 12:30:00, 08-01-14 13:00:00)
   hour -&gt;  (08-01-14 13:00:00, 08-01-14 24:00:00)
   day -&gt;  (08-02-14  00:00:00, 08-03-14 24:00:00)
   hour -&gt; (08-04-14  00:00:00, 08-04-14 12:00:00)
   min -&gt;  (08-04-14 12:00:00, 08-04-14 12:30:00)
  </code></pre>
  
  <p>I have hand rolled an implementation that works but its a little kludgy, I am looking for a) is there a library that already does that? b) if not, what would be the best way to implement this?</p>