Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgrv6-0006g5-LT for pgsql-docs@arkaria.postgresql.org; Wed, 12 May 2021 16:41:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lgrv5-00062M-IN for pgsql-docs@arkaria.postgresql.org; Wed, 12 May 2021 16:41:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgrv5-00062B-7o for pgsql-docs@lists.postgresql.org; Wed, 12 May 2021 16:41:11 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lgrv0-000718-3e for pgsql-docs@lists.postgresql.org; Wed, 12 May 2021 16:41:10 +0000 Received: by mail-lj1-x233.google.com with SMTP id v6so30401223ljj.5 for ; Wed, 12 May 2021 09:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grillet-co-uk.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=zGIH1T9yhWNoAVp3DRR5U0IdwgXgl1SwhkliI/Hbqek=; b=QWB8wbOtrJ8eV04lN25J/dhDVI7GarZxoc6BXA5GcFF/QI+pv1yXCqpsGMiSdqZq1c BIFE9tLQaNbf05Ib0TJcyCQ5joj9vF2y1mp3V6CP1VdXGeYCU+ipXdr9+JtaT1/4eobq 1BBm2IyjT3TFbAhA23x+i9G0vS8S5OxpkbNKL7LnSPUgozYUth3h4GTgyEP9vU/dhUzV zWa5EHXJvzgwCnw/GWyLfT++3TFq6ag4M4ulaQggkuOo1NifVfKmPcAY/lyS0BKXE6sW XZAck3IPRx6TIaTNJnQUD7I24bUabz+b5nKt7nQGL665Gzh49krQajq61nFGeLWFy5wq e3NQ== 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; bh=zGIH1T9yhWNoAVp3DRR5U0IdwgXgl1SwhkliI/Hbqek=; b=IdYSxEi4htpzap9q1MSUpwbgsAtbquDm7FCabHie9lt67/3dzUub3nj0lf83cI5Jfv FhhV1hsts4d4bK/MrR2ZHbI1hEUgPIrTnjyC2lNXk4RELYftlFcQjnRD/YNw7WlfAvpi llCGxeNHLptHZv0bjeIq83xBr4ImQRj0NoHUrJX7ebLOeHLZz/ChAfv0hwgBL8IXl05G brPHprU8PZegqO2L6HuhacdLx1wjDKPsmfrI8vZkCKM2WBiT7tNJpaEo43z9+3rdcm0+ h1KmWAAhLdv5HdeqZtcaHmFg5P7uQFtK4mYaotZwySUvoqBIjzZkPZuR8nQwS09zENTH Kc9Q== X-Gm-Message-State: AOAM533f8JhdYXmg/723XPPvVQIXM0uU+RLChL+p+6Neb4vm8O6Eg+xs zND7f9/DzD8EcHqpJ95n5cte3IIvREWOu67zp3iQz9ya3FXuG3dc X-Google-Smtp-Source: ABdhPJwLCfqOsrKNhjPJ/Lb8NbJw1VPYGKc2puy3XbqpeiLZEursyYXlkZgJ8x7u96WBLCd+EOtP9anp229Um5I6owc= X-Received: by 2002:a2e:2a86:: with SMTP id q128mr29982056ljq.499.1620837663559; Wed, 12 May 2021 09:41:03 -0700 (PDT) MIME-Version: 1.0 References: <162076162978.9272.2303191534467513079@wrigleys.postgresql.org> In-Reply-To: <162076162978.9272.2303191534467513079@wrigleys.postgresql.org> From: Andrew Grillet Date: Wed, 12 May 2021 17:41:42 +0100 Message-ID: Subject: Re: Handling of Invalid datetime at DST spring forward To: forrest@iris.washington.edu, Pg Docs Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Changing the DST setting for an invalid date-time is a bad move. If you do not know the date-time (because it is not valid), then you do not know whether it is the date at which the change should occur. The date of the change is different in different timezones, and if the date-time is incorrect, it could be because the timezone is set incorrectly. Not-a-number is not a number and cannot be affected by arithmetic operations. This is exactly the same situation. I think there should be a way to indicate that the date/time is invalid when read, but I can see that the side effects of not incrementing the clock would be worse than leaving it alone. Andrew Andrew On Wed, 12 May 2021 at 16:36, PG Doc comments form wrote: > > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/10/datetime-invalid-input.html > Description: > > This page > > https://www.postgresql.org/docs/10/datetime-invalid-input.html > > says a translation by +1 hour occurs for hours between 2 AM and 3 AM at DST > spring forward dates, rather than treating them as invalid, i.e., we get > 2:xx => 3:xx: > > => SELECT '2018-03-11 02:30'::timestamptz => '2018-03-11 03:30:00-04' > > This has the interesting side affect that if we dont set TZ 'UTC' then > > SELECT TSTZRANGE( '2018-03-11 02:30'::TIMESTAMPTZ , '2018-03-11 > 03:15'::TIMESTAMPTZ , '[]') > ERROR: range lower bound must be less than or equal to range upper > bound > > becomes invalid because the first date-time advances +1 hour and is now past > the second, even though that is not visible by inspecting the statement. > Too bad - suppress the error in one spot, have it pop up in another. > But I see Java has the same policy: > > LocalDateTime localDateTime = LocalDateTime.of(2005, 4, 3, 2, 30, 0); > ZonedDateTime dt = > localDateTime.atZone(ZoneId.of("America/Los_Angeles")); > String datetime_in_fmt = DateTimeFormatter.ofPattern( > "yyyy-MM-dd'T'HH:mm:ss.SSS Z" ).format( dt ); > System.out.println( String.format(" => [%s]", datetime_in_fmt )); > > converts 2:30 to 3:30: > > '2005-04-03 02:30:00' => '2005-04-03T03:30:00.000 -0700' > > Oh well.