Re: A structured format for dates?

Willy Tarreau <w@1wt.eu> Tue, 23 August 2022 14:02 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id C356EC159481 for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 23 Aug 2022 07:02:27 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.662
X-Spam-Level:
X-Spam-Status: No, score=-2.662 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hikH2Z_FgQWS for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Tue, 23 Aug 2022 07:02:23 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 9F4F9C152704 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Tue, 23 Aug 2022 07:02:23 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.94.2) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1oQURt-008Huf-JU for ietf-http-wg-dist@listhub.w3.org; Tue, 23 Aug 2022 14:00:09 +0000
Resent-Date: Tue, 23 Aug 2022 14:00:09 +0000
Resent-Message-Id: <E1oQURt-008Huf-JU@lyra.w3.org>
Received: from titan.w3.org ([128.30.52.76]) by lyra.w3.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <w@1wt.eu>) id 1oQURr-008HtR-LC for ietf-http-wg@listhub.w3.org; Tue, 23 Aug 2022 14:00:07 +0000
Received: from wtarreau.pck.nerim.net ([62.212.114.60] helo=1wt.eu) by titan.w3.org with esmtp (Exim 4.94.2) (envelope-from <w@1wt.eu>) id 1oQURp-003UUV-Mq for ietf-http-wg@w3.org; Tue, 23 Aug 2022 14:00:07 +0000
Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 27NDxfLx029712; Tue, 23 Aug 2022 15:59:41 +0200
Date: Tue, 23 Aug 2022 15:59:41 +0200
From: Willy Tarreau <w@1wt.eu>
To: Tommy Pauly <tpauly@apple.com>
Cc: Poul-Henning Kamp <phk@phk.freebsd.dk>, Roberto Polli <robipolli@gmail.com>, Mark Nottingham <mnot@mnot.net>, HTTP Working Group <ietf-http-wg@w3.org>
Message-ID: <20220823135941.GA29533@1wt.eu>
References: <202208231056.27NAuWFY015133@critter.freebsd.dk> <7B9BFDFF-337E-4CB8-8550-3D38EFD52160@apple.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <7B9BFDFF-337E-4CB8-8550-3D38EFD52160@apple.com>
User-Agent: Mutt/1.10.1 (2018-07-13)
Received-SPF: pass client-ip=62.212.114.60; envelope-from=w@1wt.eu; helo=1wt.eu
X-W3C-Hub-Spam-Status: No, score=-4.9
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, W3C_AA=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: titan.w3.org 1oQURp-003UUV-Mq c6419fe3009ed86894fa87c272ff0cd6
X-Original-To: ietf-http-wg@w3.org
Subject: Re: A structured format for dates?
Archived-At: <https://www.w3.org/mid/20220823135941.GA29533@1wt.eu>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/40342
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On Tue, Aug 23, 2022 at 06:27:14AM -0700, Tommy Pauly wrote:
> I imagine it's also a lot easier to translate *to* the human readable /
> localized format for a date from the number, since the number is an
> unambiguous form. Parsing dates the other way (from human readable to machine
> readable) is where much of the complexity and ambiguity arises, so a scheme
> that only requires transformations in one direction seems preferable. 

It's the most important aspect here IMHO: almost no error processing is
needed on a scalar. Complex fields require complex processing. Many of
us have been used to stuffing this in their scripts:

   $ date  -d "1970-01-01 00:00:$(EPOCH)"

to convert an EPOCH date to human-readable in the past, and it was quite
an ugly way to abuse a lack of control to do something useful, making
sure that once this bug would be plugged it would break such scripts.
But the equivalent impact in an HTTP field is a problem as we can easily
imagine tools validating a date using a regex and ignoring the time for
example, leaving some room for such stuff to be easy to abuse on simple
implementations.

As such, whenever I have the choice of input format between a simple atol()
and tokenizing elements that I need to feed to localtime() or gmtime(), I
do have a very strong preference for the former.

Regards,
Willy