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

Neil Jenkins <neilj@fastmailteam.com> Mon, 03 August 2020 01:35 UTC

Return-Path: <neilj@fastmailteam.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 3718F3A0EB5 for <calsify@ietfa.amsl.com>; Sun, 2 Aug 2020 18:35:06 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.197
X-Spam-Level:
X-Spam-Status: No, score=-0.197 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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=fastmailteam.com header.b=e+nzv8im; dkim=pass (2048-bit key) header.d=messagingengine.com header.b=q1tRbII/
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 TTfnJeG6bm7F for <calsify@ietfa.amsl.com>; Sun, 2 Aug 2020 18:35:04 -0700 (PDT)
Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 8423C3A0EB4 for <calsify@ietf.org>; Sun, 2 Aug 2020 18:35:04 -0700 (PDT)
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C79DB5C00F9 for <calsify@ietf.org>; Sun, 2 Aug 2020 21:35:03 -0400 (EDT)
Received: from imap7 ([10.202.2.57]) by compute4.internal (MEProxy); Sun, 02 Aug 2020 21:35:03 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= fastmailteam.com; h=mime-version:message-id:in-reply-to :references:date:from:to:subject:content-type; s=fm3; bh=IAiVP32 uaon7Dui9Jpl6cbOkRNrevG5irNePIwFCJKE=; b=e+nzv8im8Lxcy7cNdLJjAN5 vbW/PVkf6QPiRj5BGGU6GBnkafGX1yriqxfP7fnoJPU81J4iGx7YMCxO6XY4U5QL EaEqa0KBN0sR2vIJ+XZKdfyBMyxuNEd8npNlngaZzQ5G49hq0wKvV3GyoD9u8rsQ MOUqQhsujlxsj+HJdqGJzsOhIz7nOmr8gqtx7I5NRJ0FMp+zkA12S8tjCnlV49mm 8JLCAmpbKBWkdwb+pAWXnnd7qkYswlsaHfA4maHoA1Nv/YwRjr2qdzJ9gFnB43L+ NIsVMxy/FVPMHFtmbzYh8HFnG61sRQkTQFGhWygQG/D088PRhfCJdSowd2Wquzw= =
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=IAiVP3 2uaon7Dui9Jpl6cbOkRNrevG5irNePIwFCJKE=; b=q1tRbII/vn7jaXV1H9++Rt UPnpD/u2KA3a97nd+zrmUoijaUPah/qwu+0NFrMLa/Ozz6e+wMH0UbskzPTtYhDW IE+PBtMRosQT2B2dCR8uhWsmFKF9EjAzH5rI0zRFO4kfitRHeoq6bO9UzRa5J8f9 eopJi/ZY+RbODbo9TS1CIytTF8I9Fren7812XoNtU4arTMITlBg7B6w1P3xAadA2 x3QrvJwoyAZZgnPvYhEZTLIMKQK4XjI5bzLIxCmrfGukPhFrkV3ikOz5pb7vONgm YIi4BYx+FIW15gSj/+NNccT2y2LpbkK22JKx4qpcBz9SwAyR3OJzeBLr7xVdUtGA ==
X-ME-Sender: <xms:x2knXzhcbssrkNyygcOGBuhsdrX62jMiPzu9V7R4PIiAgiwn0GjKhA>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrjeefgdegiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrgdtre erreerjeenucfhrhhomhepfdfpvghilhculfgvnhhkihhnshdfuceonhgvihhljhesfhgr shhtmhgrihhlthgvrghmrdgtohhmqeenucggtffrrghtthgvrhhnpeehuefhudejtdeive ekvdfhfffgleeflefhfeekhefhkeelkefhfeeufeevffejieenucevlhhushhtvghrufhi iigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehnvghilhhjsehfrghsthhmrghilh htvggrmhdrtghomh
X-ME-Proxy: <xmx:x2knXwCwbaDdTx9YncEXpni1HyJHFL1fQnk71P_zBrtxTF4mIL-iCw> <xmx:x2knXzFINBLiLYEZswsegUsJw4cGlSrumcPx6PzdL2GReAvmh_v2gw> <xmx:x2knXwQvLgmcXbLmVopVYGaImfqVGv59Uoi-IfIp7dlMn32rEN9QyA> <xmx:x2knXwhGYLvLQhATfLgOCn96A4xdKA-NyOWpiBdi61jrMDGwgt2Omg>
Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7129E18057E; Sun, 2 Aug 2020 21:35:03 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.3.0-128-gd51a832-fm-20200728.001-gd51a8328
Mime-Version: 1.0
Message-Id: <5bfd4453-e9a9-4bf4-b403-1b2f19cc790a@dogfood.fastmail.com>
In-Reply-To: <CACy7CficiNXA_tb01c0=PWQTnXPVu_e7TgWAKUVPY-ow9C=3SQ@mail.gmail.com>
References: <CACy7CficiNXA_tb01c0=PWQTnXPVu_e7TgWAKUVPY-ow9C=3SQ@mail.gmail.com>
Date: Mon, 03 Aug 2020 11:35:02 +1000
From: Neil Jenkins <neilj@fastmailteam.com>
To: calsify@ietf.org
Content-Type: multipart/alternative; boundary="80b09d0a88be4374b279264097ca5157"
Archived-At: <https://mailarchive.ietf.org/arch/msg/calsify/yCHEZMqNcyzpWcuS7NgDmfSp26Q>
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: Mon, 03 Aug 2020 01:35:06 -0000

On Sun, 2 Aug 2020, at 13:04, Justin Grant wrote: 
> > Q1. [...] I'm not sure why you think the disambiguation in the middle is going to be problematic for users; surely they generally won't notice where it happens? 
> 
> Here's an example: what should be the result of adding P1DT12H to 2020-03-07T02:30-08:00[America/Los_Angeles]. My understanding of RFC5545's algorithm is that we'd use the following steps:
>   A) Add 1 calendar day.
>   B) Add 12 exact hours (not clock hours)
> But the after step A, the local time is not valid because 2020-03-08T02:30 is in the middle of the hour skipped by a DST transition. My interpretation of RFC 5545 is that we'd interpret the invalid intermediate time by using the offset before the transition, so we'd end up with an intermediate value of 2020-03-08T03:30-07:00[America/Los_Angeles] and a final result of 2020-03-08T15:30-07:00[America/Los_Angeles].  Is this correct?

Yes, that's my understanding too.

> Are both of these compliant with your understanding of RFC 5545?  Is only one correct?  Or is neither correct?
> 
> 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).

OK, so I think I see the cause of the confusion. They are both correct(!) BUT this is because there is a subtle difference between the Temporal *LocalDateTime* and RFC5545 *Date with local time and time zone reference*. The latter does not have a UTC reference point; it's just a wall clock time.

You can add either P1D or P1DT1H to 2020-10-31T01:30 and get a wall clock time of 2020-11-01T01:30. Both are correct durations to calculate as the difference between X and Y, because Y could be two different absolute times (the -08:00 is not encoded in the RFC5545 model).

Due to conversion rules, when converting to UTC you always interpret 2020-11-01T01:30[America/Los_Angeles] as -07:00, not -08:00, should you need an absolute time. If you want to reference the other point in time specifically you would need to use UTC (or I guess any time zone where it is unambiguous).

Note, in general the lack of offset encoded with the time zone is a feature not a bug; otherwise you end up with nonsensical data should the time zone definitions change (what would you do with 2020-11-01T01:30-08:00[America/Los_Angeles] should California suddenly decide to join the One Glorious US Average Time Zone of -06:30?!). If the offset is fixed, you need to use UTC (or a fixed offset zone like Etc/GMT+8), not a real time zone.

> Another problem is that the logic above can deliver unexpected results depending on the local time of the endpoints, even if neither of those endpoints are close to a DST transition.  For example, using the "Addition Path" logic above, here's the durations that the following pairs of LocalDateTime values will return: 
>  * 2020-03-07T01:30-08:00[America/Los_Angeles] to 2020-03-08T13:30-07:00[America/Los_Angeles] => P1D12H

I think this one is incorrect. Following your Addition Path algorithm:

  A) Let D = Y - X => 1 day 12 hours
  B) Truncate the time portion of D => 1 day
  C) Let I = X+D => 2020-03-08T01:30[America/Los_Angeles] => 2020-03-08T09:30:00Z
  D) Y = 2020-03-08T20:30:00Z; I - Y => 11H
  E) Merge N and T: P1DT11H

>  * 2020-03-07T02:30-08:00[America/Los_Angeles] to 2020-03-08T14:30-07:00[America/Los_Angeles] => P1D11H (1 hour less because the intermediate time 2020-03-08T02:30 is resolved to 2020-03-08T03:30-07:00[America/Los_Angeles] before the exact time difference is calculated)
>  * 2020-03-07T03:30-08:00[America/Los_Angeles] to 2020-03-08T15:30-07:00[America/Los_Angeles] => P1D12H
> 
> Users probably won't be surprised to see divergent results in cases where the endpoints are within an hour of a DST transition. But what's unexpected is the variation in results caused by the intermediate result landing on an invalid time, even though neither of the endpoints are very close to the transition.
> 
> Does this clarify the problems we're trying to resolve with Q5?

I think I see. So the issue you have is if the end day is a daylight savings transition *day* and the start time is prior to the daylight savings transition *time*, then you have the intermediate adjustment which may be surprising to users. Firstly, this is actually going to be very rare that you hit it (so the likelihood of someone coming across it and actually *being *surprised is minimal, and the issue is the surprise, not necessarily the semantics); secondly, I think you would have to change the interpretation of durations (Q1) in order to do anything different, which seems a breaking change for minimal gain in my view.

Neil.