Calculating the difference between two dates in Swift : <p>I've seen many approaches how to compute the difference between two dates in terms of a particular date component, e.g. in days, hours, months etc. (see <a href="https://stackoverflow.com/a/27184261/2062785">this answer on Stackoverflow</a>):</p>

<pre><code>Calendar.current.dateComponents([.hour], from: fromDate, to: toDate).hour
Calendar.current.dateComponents([.day], from: fromDate, to: toDate).day
Calendar.current.dateComponents([.month], from: fromDate, to: toDate).month
</code></pre>

<p>What I haven't seen is how to make calculations with the actual <code>Date</code> objects. Something like</p>

<pre><code>func computeNewDate(from fromDate: Date, to toDate: Date) -&gt; Date    
     let delta = toDate - fromDate
     let today = Date()
     if delta &lt; 0 {
         return today
     } else {
         return today + delta
     }
}
</code></pre>

<p>I have seen the <a href="https://developer.apple.com/documentation/foundation/dateinterval" rel="noreferrer"><code>DateInterval</code></a> type which as introduced in iOS 10 but according to the documentation</p>

<blockquote>
  <p>[it] does not support reverse intervals i.e. intervals where the duration is less than 0 and the end date occurs earlier in time than the start date.</p>
</blockquote>

<p>That makes it inherently difficult to calculate with dates – especially when you don't know which one is the earlier date.</p>

<p><strong>Is there any clean and neat approach to compute time differences between <code>Date</code>s directly</strong> (and adding them to <code>Date</code> instances again) <strong>without computing with their <code>timeIntervalSinceReferenceDate</code>?</strong></p>
