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 1mSjUY-0005ZE-72 for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 17:23:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mSjUW-0002ad-0r for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 17:23:36 +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 1mSjRP-0004yp-9G for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 17:20:23 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSjRF-0001lD-3K for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 17:20:22 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 60C03568A; Tue, 21 Sep 2021 19:20:10 +0200 (CEST) Date: Tue, 21 Sep 2021 19:20:10 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Re: Timestamp with vs without time zone. Message-ID: Mail-Followup-To: pgsql-general@lists.postgresql.org References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5vnEU/8ujjPaLQPU" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --5vnEU/8ujjPaLQPU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2021-09-21 20:50:44 +1200, Tim Uckun wrote: > That's all true and I won't argue about the madness that is timezones > in the world. I am simply thinking it would be some sort of a struct > like thing which would store the numerical value of the time stamp and > also the time zone that time was recorded in. Presumably everything > else is an insane calculation from there. What was the offset on that > day? I guess it depends on the daylight savings time. What would the > conversion to another time zone be? That would depend on the DST > settings on that day in both places. Yes, but HOW IS THAT TIME ZONE STORED?=20 As a user you can say "I don't care, just make it work somehow". But as a developer you have to decide on a specific way. And as a database developer in particular you would have to choose a way which works for almost everybody. And that's the problem because ... > Mankind can't agree on what side of the road to drive on, what the > electrical voltage should be at the wall, what those plugs should be, > how you should charge your phone or anything else for that matter =2E.. people have different needs and it would be difficult to satisfy them all. Simply storing an offset from UTC is simple, fast, doesn't take much space - but it would be almost as misleading as the current state. A simple offset is not a time zone. Storing the IANA timezone names (e.g. 'Europe/Vienna') would store an identifier for what most people think of as a time zone - but that takes a lot of space, it needs a lookup for almost any operation and worst of all, you couldn't index such a column (at least not with a btree index) because the comparison functions aren't stable. You could use a numeric indentifier instead of the name, that would take less space but wouldn't solve the other problems (and add the problem that now you have just added another mapping which you need to maintain). There are other ways, but I'm sure they all have some pros and some cons. None will be perfect. So I don't think there is an obvious (or even non-obvious, but clearly good) way for the PostgreSQL developers to add a real "timestamp with timezone" type. As an application developer however, you can define a compound type (or just use two or three columns together) which satisfies the needs of your specific application. > It's just that the phrase "timestamp with time zone" would seem to > indicate the time zone is stored somewhere in there. I absolutely agree. Calling a type which doesn't include a timezone "timestamp with timezone" is - how do I put this? - more than just weird. "timestamp without timezone" should be called "local timestamp with unspecified timezone" and "timestamp with timezone" should be called "global timestamp without timezone". However, those aren't SQL names. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --5vnEU/8ujjPaLQPU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmFKFEUACgkQ8g5IURL+ KF37+Q/9GiblJ86IO7d6XzxJ45EOYGvhG5ucp2cuqMQzHsBN0l+5Glufd12XVu8X +zViLSjitWVJRCJJuh70rzk0bSKQe+K5kdQQoNpqXvHEbUMTYUsOVEI0BERaJPCe yCpDHMnEegDtXSk34a0w0HDNWHTF55HiUQnWVBuVqfmUQS6cgU8kKSDT7tL93lF9 74dMu3Cm+2PK5UDW/A1QX8AjCoUCd5XaWt8PJDCWgrBFXQK4AdpNwPgbNyrKqq0M oG4HWei58dnO6vMITBdunHISfeDLiEXButgN7sQB6k+I/EUFB2ASGt9OEqTveht1 ahn4jgfF27qUT7HWkz7jN/MQkFRKXwk6NSAPGI05f/qhQo668DEn0lBEQcQCTVJg bN+YnW/rcDCk7zxAx10Ow1My50DoCM89RXqMV+H3ODoYtslnbZYUujdI8jwKJIXw emf6T9jUo2gHXU5wai4gfFU7xcjYUmj7VrXxGKNF964BTFTgBmASA5A9wwHDyIe3 gaoRd+XvSlKn0NEnCVdw/uqUat6VBo21lNnAYIAkQfxFsS+CMojPNJTVAn3lmfBa VBrxakn8NTjRa2j9gM5FIivMAQunAOOtkYuH4xFEd+FmFOuS8LDnivyXY74Gxj5h EtQOtK1j4I4Exa/lOeUkFEYueUcCmt3XV6Tu2DEvH0kHh0mq4Ig= =GAV+ -----END PGP SIGNATURE----- --5vnEU/8ujjPaLQPU--