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 1lMF09-00045c-6g for pgsql-general@arkaria.postgresql.org; Tue, 16 Mar 2021 19:05:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lMF06-0000xU-FX for pgsql-general@arkaria.postgresql.org; Tue, 16 Mar 2021 19:05:06 +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 1lMF06-0000xN-7m for pgsql-general@lists.postgresql.org; Tue, 16 Mar 2021 19:05:06 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lMEzw-0004LU-OF for pgsql-general@lists.postgresql.org; Tue, 16 Mar 2021 19:05:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 12GJ0tHg3388508; Tue, 16 Mar 2021 15:00:55 -0400 From: Tom Lane To: Ruslan cc: pgsql-general@lists.postgresql.org Subject: Re: Binary encoding of timetz type In-reply-to: References: Comments: In-reply-to Ruslan message dated "Tue, 16 Mar 2021 18:30:39 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3388506.1615921255.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 16 Mar 2021 15:00:55 -0400 Message-ID: <3388507.1615921255@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ruslan writes: > I wrote parser for COPY binary encoding. Everything is great but one thi= ng > worries me. It seems like the time offset field has reversed digit sign. > I'm referring to this function > https://github.com/postgres/postgres/blob/REL_13_STABLE/src/backend/util= s/adt/date.c#L2150-L2159 Reversed compared to what? The code you quote is clearly sending the internal representation as-is. There's a lot of confusion in the world about whether positive timezone offsets correspond to being east or west of Greenwich (not helped any by the fact that there are relevant standards using both interpretations). I think that our internal form uses positive-is-west, a/k/a POSIX rules, but I'm too lazy to go check right now. regards, tom lane