Subject: Re: [calsify] RFC 5545/JSCalendar questions from ECMAScript TC39 "Temporal" working group

From: "Neil Jenkins" <[email-masked]>
Date: Mon, 05 Oct 2020 09:44:13 +1100

On Wed, 30 Sep 2020, at 09:44, Justin Grant wrote:
> I think this result is probably OK (because DST is weird) but I'm wondering if the difference calculation in this case should return P1D (which makes `end - start == P1D`) or P1DT1H (which would make `undo == start`). Or is there some possible algorithm which could make both comparisons true? 

With this example, there are two different values of D that can be added to START that both result in the same END: P1D or P1DT1H. Therefore END - START could return either of those two values. You cannot guarantee that DIFF is the same as D, because from just END and START there is insufficient information to tell you which duration value was used.

> If not, then would it be better for the first comparison to work and the second to fail, or is it better for the second to work and the first to fail?

I would say the second one is the important one (as we already know the first one is impossible!):

> * let DIFF = END - START
> * let UNDO = END - DIFF
> * assert DIFF == D
> ** assert UNDO == START*

Neil.