Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sL3Yw-00DGkq-2S for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Jun 2024 16:26:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sL3Yr-00BXKh-MO for pgsql-hackers@arkaria.postgresql.org; Sat, 22 Jun 2024 16:25:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sL3Yr-00BXHN-4d for pgsql-hackers@lists.postgresql.org; Sat, 22 Jun 2024 16:25:57 +0000 Received: from pb-smtp20.pobox.com ([173.228.157.52]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sL3Yj-002anN-2G for pgsql-hackers@lists.postgresql.org; Sat, 22 Jun 2024 16:25:55 +0000 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 940353D36A for ; Sat, 22 Jun 2024 12:25:46 -0400 (EDT) (envelope-from david@justatheory.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:to; s=sasl; bh=PAOkaNCKMNISRbQX5r2rtM6YkvVeVH9y uSAQD1HRcSM=; b=Mz22XvJxlnmbrGEJwEPTwHIg5T4ob9relU7MFT+ISAmeolog SH+kj6gmAAsdXHw2vMRLcJT1wg9WIdeTsCmdCDrz31uOHWpNdm2v22Yk1/2f18px b8sVM6vv2Ql8reR4bIbRxQhPiJP1EmQpP2gB7w7Nr2+0UfbS2iN0I0aYmoo= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 8C8D23D369 for ; Sat, 22 Jun 2024 12:25:46 -0400 (EDT) (envelope-from david@justatheory.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=justatheory.com; h=from:content-type:content-transfer-encoding:mime-version:subject:message-id:date:to; s=2016-12.pbsmtp; bh=PAOkaNCKMNISRbQX5r2rtM6YkvVeVH9yuSAQD1HRcSM=; b=CZ8YPqMoA4GSbllVJpuRDd+pGttORU0Q0stq18zaGggrB+XEXkpBb9mTHWex93gGHdEOqzZBGHAG7/PE1Q+7gHcCHy7bhb0OV6i1RU8IQRR41ekPQHVZFDbqz3+F/fokIfc8JswLY56WL4ywk6fm5WyjvjT7iglIFRQ0Ael6/50= Received: from smtpclient.apple (unknown [158.222.197.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 40D5F3D364 for ; Sat, 22 Jun 2024 12:25:42 -0400 (EDT) (envelope-from david@justatheory.com) From: "David E. Wheeler" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Inconsistent Parsing of Offsets with Seconds Message-Id: Date: Sat, 22 Jun 2024 12:25:29 -0400 To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3774.500.171.1.1) X-Pobox-Relay-ID: 11DD20AC-30B4-11EF-98A1-C38742FD603B-76319746!pb-smtp20.pobox.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hackers, The treatment of timestamptz (and timetz) values with offsets that = include seconds seems a bit inconsistent. One can create such timestamps = through the input function: david=3D# select '2024-06-22T12:35:00+02:30:15'::timestamptz; timestamptz =20 ------------------------ 2024-06-22 10:04:45+00 But the offset seconds are dropped (or rounded away?) by = to_timestamp()=E2=80=99s `OF` and `TZ` formats[2]: david=3D# select to_timestamp('2024-06-03 12:35:00+02:30:15', = 'YYYY-MM-DD HH24:MI:SSOF'); to_timestamp =20 ------------------------ 2024-06-03 10:05:00+00 david=3D# select to_timestamp('2024-06-03 12:35:00+02:30:15', = 'YYYY-MM-DD HH24:MI:SSTZ'); to_timestamp =20 ------------------------ 2024-06-03 02:05:00-08 The corresponding jsonpath methods don=E2=80=99t like offsets with = seconds *at all*: david=3D# select jsonb_path_query('"2024-06-03 12:35:00+02:30:15"', = '$.datetime("YYYY-MM-DD HH24:MI:SSOF")'); ERROR: trailing characters remain in input string after datetime format david=3D# select jsonb_path_query('"2024-06-03 12:35:00+02:30:15"', = '$.timestamp_tz()'); ERROR: timestamp_tz format is not recognized: "2024-06-03 = 12:35:00+02:30:15" I see from the source[1] that offsets between plus or minus 15:59:59 are = allowed; should the `OF` and `TZ formats be able to parse them? Or = perhaps there should be a `TZS` format to complement `TZH` and `TZM`? Best, David [1] = https://github.com/postgres/postgres/blob/70a845c/src/include/datatype/tim= estamp.h#L136-L142 [2]: https://www.postgresql.org/docs/16/functions-formatting.html