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

Justin Grant <justingrant.ietf.public@gmail.com> Sat, 15 August 2020 19:16 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 6B7AF3A0B0C for <calsify@ietfa.amsl.com>; Sat, 15 Aug 2020 12:16:33 -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 MoAsr5Op6NWu for <calsify@ietfa.amsl.com>; Sat, 15 Aug 2020 12:16:31 -0700 (PDT)
Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) (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 7CC513A0995 for <calsify@ietf.org>; Sat, 15 Aug 2020 12:16:31 -0700 (PDT)
Received: by mail-ej1-x629.google.com with SMTP id bo3so13313743ejb.11 for <calsify@ietf.org>; Sat, 15 Aug 2020 12:16:31 -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=dU1FVdeJ8VeE4FfsgBWI6RbPGnbXZto1Tu2rfk7WOfk=; b=dY2R4uhBNfE5rpMSicolJY5NxOs4jFlcuaCB1ZK+lj/11NYVLb7urp7y2LNW2+TAU7 Jlmu8LyjqzD2xy7UAEZIPtap7vgedrcoC1Z9roFTXIhkBBqNY/WGVfZ2LmIGK0dcslLK q+0tB/eRH44xFq/Qz/bOUke/mxqJ49fTeLIhKddgxThI9BrEzbhh4XIUH3tNIKyc9Md8 mRfNl7betAa4VrY/M+xaNokYGXFuAa1wIUV+Qbo2cgx13BMlu2PvFQPZnZvGW3n8rGm1 tp9sqh0Pep0R1fshIxnTo+xJiLMjmq1wfGXYjqn6eKvoypBqYwk3EuR0vTXxvc/Pth5K kUCA==
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=dU1FVdeJ8VeE4FfsgBWI6RbPGnbXZto1Tu2rfk7WOfk=; b=rL2IwJOlh8j+j1e+r3upESeQuLbsR3iTo3N3uIZm3t3KDN4S80x2T/EFiRF8oqdAB1 680g1TwelLLKgP7XoGKMT+mHpk3T29kvtQSwPKyZjJQeNDJFJ790a4ajx/qAE4XcZSgx 7ywkne73Ct7L25Wb3oALqJmNXeDdSFuVfGUuEilgbsgvgkQBLAO6LyNW/SYhhpJgSedA 9Zp04gfrlw4VuM0AX0qyi9BKY9pOwHOm+D/jZ68kpZIy2gOJlwsdujWPaM8vREkaWmYr niomC9hcGG4ATXOC8tj5/u2xe7A9hZJSn10Dsb6rRWsjc43XSfn+REy6hXCaFNwZfq/M yoOA==
X-Gm-Message-State: AOAM531Fvdi8hnLZgVMwFZdvKbJJZAMvk3diW2/SYcWpx2PORjFQtf/J l1tCV5Z53hp1JiPREqhvgH5WSq31NhgiQx5u4MOfi7SJQGA=
X-Google-Smtp-Source: ABdhPJzEKbqVc0bx8/iPWmjZcgz1xynR8erZfMoC+asoJxAeSQNLPMWr2gfj3GpLB0STJPXyAucf78LyW3BFpHwMYmA=
X-Received: by 2002:a17:906:7c4f:: with SMTP id g15mr7898503ejp.82.1597518989916; Sat, 15 Aug 2020 12:16:29 -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> <CACy7Cfjfdu7yyjvVCcvYag7AVMrekqiSCfm6pQZ8PiQLFiJ7Aw@mail.gmail.com>
In-Reply-To: <CACy7Cfjfdu7yyjvVCcvYag7AVMrekqiSCfm6pQZ8PiQLFiJ7Aw@mail.gmail.com>
From: Justin Grant <justingrant.ietf.public@gmail.com>
Date: Sat, 15 Aug 2020 12:16:19 -0700
Message-ID: <CACy7CfgBBHxu=gHirXs3xVc30psU0+F-E0ttiUiJ4KvSCR9Qew@mail.gmail.com>
To: Neil Jenkins <neilj@fastmailteam.com>
Cc: calsify@ietf.org
Content-Type: multipart/alternative; boundary="000000000000ea7c9e05acef5fdb"
Archived-At: <https://mailarchive.ietf.org/arch/msg/calsify/yaBq5MOAaxrLQiy-70U-Qv8qMWg>
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: Sat, 15 Aug 2020 19:16:33 -0000

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

On Thu, Aug 6, 2020 at 11:17 PM Justin Grant <
justingrant.ietf.public@gmail.com> wrote:

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