pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Binary encoding of TIMESTAMP WITH TIME ZONE
Date: Fri, 5 Jun 2020 17:30:57 +0200
Message-ID: <20200605153057.GA11484@hjp.at> (raw)
In-Reply-To: <1375425.1591317171@sss.pgh.pa.us>
References: <ae9774ef-ad25-a0bc-6f4b-208ba1880b3a@freedomcircle.com>
	<1375425.1591317171@sss.pgh.pa.us>

On 2020-06-04 20:32:51 -0400, Tom Lane wrote:
> Joe Abbate <jma@freedomcircle.com> writes:
> > However, when using the same query using the Rust adapter the transition 
> > to a new row started showing up after midgnight GMT.  I opened an issue 
> > on Github (https://github.com/sfackler/rust-postgres/issues/608 ) and 
> > the maintainer claimed the Rust adapter *had* to initialize timezone to 
> > UTC in order to properly convert "to and from time datatypes".  I 
> > pointed out that the timezone offset is available in psql and psycopg2, 
> > but then he replied the binary encoding of timestamptz does *not* 
> > include the timezone offset.
> 
> Indeed it does not, just as the on-disk format for it does not.  The
> representation is effectively always in UTC.  If you have some other
> timezone setting selected, timestamptz_out rotates to that zone for
> display purposes ... but the binary format doesn't.

However, the explanation still sounds off. I'm not familiar with Rust,
but I wouild expect the Rust time type to be based on Unix time_t or
some variant of it (maybe milliseconds as in Java, or nanoseconds or a
different epoch). That also doesn't include a timezone, so conversion
should be straightforward and not require any timezone to be involved.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (3+ messages)

Message-ID: <20200605153057.GA11484@hjp.at>
Permalink:  ../20200605153057.GA11484@hjp.at/
Also on:    postgresql.org/message-id/20200605153057.GA11484@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Binary encoding of TIMESTAMP WITH TIME ZONE
  In-Reply-To: <20200605153057.GA11484@hjp.at>
  References: <ae9774ef-ad25-a0bc-6f4b-208ba1880b3a@freedomcircle.com> <1375425.1591317171@sss.pgh.pa.us> <20200605153057.GA11484@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox