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

From: Justin Grant <[email-masked]>
Date: Tue, 29 Sep 2020 16:43:16 -0700

Hi Neil - I'm working on a sample implementation of the algorithms we've
been discussing for addition, subtraction, and calculating the difference
between date/time values.

I'm trying to figure out if there's an algorithm that can make all
operations reversible, meaning that the last two comparisons below should
be true:
* let START = some date/time value with a time zone
* let D = some duration
* let END = START + D
* let DIFF = END - START
* let UNDO = END - DIFF
* assert DIFF == D
* assert UNDO == START

But if E falls inside a DST skipped hour, then I'm not sure that both the
comparisons can be true. Example:

* START = 2020-03-07T02:30-08:00[America/Los_Angeles]
* D = P1D
* END = START + D == 2020-03-07T03:30-07:00[America/Los_Angeles]
* DIFF = END - START == P1D (OK)
* UNDO = END - DIFF == 2020-03-07T03:30-08:00[America/Los_Angeles]
* UNDO != START (3:30 vs. 2:30)

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?  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?

Cheers,
Justin

On Sun, Aug 16, 2020 at 4:39 PM Neil Jenkins <[email-masked]> wrote:

> On Sun, 16 Aug 2020, at 05:16, Justin Grant wrote:
>
> Hi Neil - reviewing this now. Had a quick question:
>
> > Let T = Y - X in absolute time => PT23H45M
>
> Why is X used here instead of I?  Here's what I would have expected:
>
> Let T = Y - *I* in absolute time  => PT23H45M
>
>
> Correct. This was an error, it should be *I* as you say.
>
> Neil.
>

---

From: Justin Grant <[email-masked]>
Date: Tue, 29 Sep 2020 16:44:26 -0700

BTW, "But if E falls inside a DST skipped hour" should have read "But if
END falls inside a DST skipped hour"

On Tue, Sep 29, 2020 at 4:43 PM Justin Grant <
[email-masked]> 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?  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?
>
> Cheers,
> Justin
>
>