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

Justin Grant <justingrant.ietf.public@gmail.com> Fri, 07 August 2020 06:17 UTC

Return-Path: <justingrant.ietf.public@gmail.com>
X-Original-To: calsify@ietfa.amsl.com
Delivered-To: calsify@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 617433A03ED for <calsify@ietfa.amsl.com>; Thu, 6 Aug 2020 23:17:28 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.097
X-Spam-Level:
X-Spam-Status: No, score=-2.097 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n3f0aHyQ7Yjh for <calsify@ietfa.amsl.com>; Thu, 6 Aug 2020 23:17:27 -0700 (PDT)
Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id AB39D3A0141 for <calsify@ietf.org>; Thu, 6 Aug 2020 23:17:26 -0700 (PDT)
Received: by mail-ed1-x534.google.com with SMTP id q4so428622edv.13 for <calsify@ietf.org>; Thu, 06 Aug 2020 23:17:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Pd7NH+SOwZFcJyODxZgA+FD5IVlcHgWo3sx1VZ+L4Hk=; b=L5CozhJUGgNCx9OXu2BiMJpdD6U5RQb1okrAVUWxPBD2IbSMJmA9lgvL3DdMEYWTgL tXcetJP8KW2fid2kPM5e5bSPxVpiUurHb5qX6fSkI75uXpo8MFafP+1qoFjhMJWszRg3 Iht6A1V7qEWMWoX1oat5T15gKEXQ1I1MNCtrNj0lhL5w6zedPxQdnfU5264Z+RJa+b6y NX+OIInPgzXEawA9O1ns+lF32jJlujXtuFIGhOaqtDzcGydezCwdU/V99j+rP7JwlxMG Ydcl6MuvDQtdfOUAO5k5TyJHmA/7MWHNs/hjKYz927GhLKRHllREJDGzoGsc3W2nCzl1 PpOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Pd7NH+SOwZFcJyODxZgA+FD5IVlcHgWo3sx1VZ+L4Hk=; b=AJLxj9auSbfHfPwWBj8uJpxNAbQ0puUT+a/Dc8Wwh7aqUgAKVaWQ/N+6GWofXwSrR5 P52ak/NO/SfUXvbEek2B260n0yKR1EBi/bwl1GbL431DGI5zc4vEkoUr32uzQgbCE1Kl yj8E5aIEUe/CnE1I+L8iT5wG7mj/evqzxrevQf1gDoJ2Ne3mZTm/H7i3SI6AkjUVS8aq whG/ruH5lJKbjoNxSZHcSPoR3qz/kdBGpIx7NwwIkFelVVsFBUgbvPtFFf3fFOpT5d0c ZOKugNoxk2lLJVNkL7H9XVKbXjm9LvmrenJJlPjGmeQdytgIh7L9c3S1SL2ITtDKmbtJ xIxA==
X-Gm-Message-State: AOAM530rKdBG0Qi/Ca5HVcLbIvU+07PAlHrp3rIYBVpmsXzPZVuwmUyx 8vQ6/uWKq6noqDDlWejI3WVEGD+ag1BeH7p8ZnKyyQ==
X-Google-Smtp-Source: ABdhPJxTvsI11Q64fD8Am+c7JFGYni4+IlWHgc1ttkRstQqKu1UH2DHdVN8hN4i7Lw4LFUgTHOfh35sg4NkQbpcfM0s=
X-Received: by 2002:a50:ef04:: with SMTP id m4mr7555127eds.63.1596781045176; Thu, 06 Aug 2020 23:17:25 -0700 (PDT)
MIME-Version: 1.0
References: <CACy7CficiNXA_tb01c0=PWQTnXPVu_e7TgWAKUVPY-ow9C=3SQ@mail.gmail.com> <5bfd4453-e9a9-4bf4-b403-1b2f19cc790a@dogfood.fastmail.com> <CACy7CfgbPG_ugC59CZWtMwA7w4UOJR=zUkovKzvHUdeoFxnpjg@mail.gmail.com> <6d357b96-9899-4bd3-93e0-97e147a86a4d@dogfood.fastmail.com>
In-Reply-To: <6d357b96-9899-4bd3-93e0-97e147a86a4d@dogfood.fastmail.com>
From: Justin Grant <justingrant.ietf.public@gmail.com>
Date: Thu, 06 Aug 2020 23:17:14 -0700
Message-ID: <CACy7Cfjfdu7yyjvVCcvYag7AVMrekqiSCfm6pQZ8PiQLFiJ7Aw@mail.gmail.com>
To: Neil Jenkins <neilj@fastmailteam.com>
Cc: calsify@ietf.org
Content-Type: multipart/alternative; boundary="000000000000fb5c7005ac438e8d"
Archived-At: <https://mailarchive.ietf.org/arch/msg/calsify/J4R7oqt4QVrUwO730rzBfKG9jkk>
Subject: Re: [calsify] RFC 5545/JSCalendar questions from ECMAScript TC39 "Temporal" working group
X-BeenThere: calsify@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: <calsify.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/calsify>, <mailto:calsify-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/calsify/>
List-Post: <mailto:calsify@ietf.org>
List-Help: <mailto:calsify-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/calsify>, <mailto:calsify-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Aug 2020 06:17:28 -0000

Hi Neil - Apologies for slow response, I'm on vacation for a few days. At
first glance your proposal above looks good to me but I'll need to review
more closely without "vacation brain" when I get back next week.

Cheers,
Justin


On Mon, Aug 3, 2020 at 8:34 PM Neil Jenkins <neilj@fastmailteam.com> wrote:

> On Mon, 3 Aug 2020, at 14:46, Justin Grant wrote:
>
> Yep, agreed. This is a rare use case so it's definitely not worth a
> breaking change. Our goal is to find a deterministic, least-surprising
> solution for this weird case.  Ideally someone else would have already
> standardized how to handle this case and we could just adopt the standard,
> but so far I haven't found it.
>
> Does JSCalendar include any guidance about how to calculate durations from
> two date/time+timezone (DATE-TIME - FORM #3) values?  If not, would you
> be interested in collaborating with us to define an algorithm that could be
> used by Temporal and included in the JSCalendar spec? This may help with
> interop.
>
>
> We don't have anything currently defined, but I am interested in adding
> it; I agree it could be useful for interop.
>
> Finally, could you explain what you mean by "*I think you would have to
> change the interpretation of durations (Q1) in order to do anything
> different"* ?
>
>
> What I mean is that the addition operation of a duration to a date is well
> defined, and we don't plan to change it. Therefore, the “correctness” of an
> algorithm for calculating a duration between dates X and Y is constrained
> by the simple fact that the duration "D" that results must be such that X +
> D = Y.
>
> The Temporal case is further constrained because you are representing both
> sets of dates in overlapping time periods. Therefore to go back to the
> example you gave in the previous email:
>
> One problem is that the Addition Path and the Subtraction Path can return
> different results when an endpoint is in the "repeated hour" after DST ends
> in the fall. For example, assume that X is
> 2020-10-31T01:30-07:00[America/Los_Angeles] and Y is
> 2020-11-01T01:30-08:00[America/Los_Angeles] (the "second" 1:30AM on the day
> DST ends).  If we start from X, then we'd add one nominal day to get
> 2020-11-01T01:30-07:00[America/Los_Angeles] (the "first" 1:30AM), and then
> add one exact hour to get to the end. So the result is P1DT1H.  But if we
> start from Y, then subtracting one nominal day from
> 2020-11-01T01:30-08:00[America/Los_Angeles] yields
> 2020-10-31T01:30-07:00[America/Los_Angeles]. There is no time remainder. So
> the result is P1D.
>
>
> As I said before, both of these durations are arguably valid in RFC5545.
> However in Temporal, the Subtraction one is not valid:
>
>    - X = 2020-10-31T01:30-07:00[America/Los_Angeles]
>    - Y = 2020-11-01T01:30-08:00[America/Los_Angeles]
>    - D = P1D (by the subtraction method)
>    - X + D = 2020-11-01T01:30-07:00[America/Los_Angeles] ≠ Y
>
>
> The "Addition" algorithm however does produce the correct result, and I
> think is a reasonable basis for an algorithm to adopt. The one change I
> think it needs is to account for when the time of the earlier date is in
> the no-mans-land of a DST transition, and the end day is on a transition
> day. e.g.
>
>    - X = 2020-03-06T02:30-08:00[America/Los_Angeles]
>    - Y = 2020-03-08T03:15-07:00[America/Los_Angeles]
>
> If you try to use the Addition Path:
>
>    - Let D = Y - X ignoring TZ => P2D
>    - Let I = X+D => 2020-03-08T02:30 =>
>    2020-03-08T03:30-07:00[America/Los_Angeles] according to resolution rules,
>    which is after Y.
>
> So I think that we just need to add an extra check at step (C): if you get
> an absolute time *after* the end time Y, subtract 1 day from the duration
> and try again. e.g.
>
>    - Let D = P2D - 1 day => P1D
>    - Let I = X+D => 2020-03-07T02:30-08:00[America/Los_Angeles]
>    - Let T = Y - X in absolute time => PT23H45M
>    - Result = D + T => P1DT23H45M
>
>
> Neil.
>
>