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 1mSlse-00030k-GC for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 19:56:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mSlsd-00035R-DJ for pgsql-general@arkaria.postgresql.org; Tue, 21 Sep 2021 19:56:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSlsc-00035J-AB for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 19:56:39 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mSlsY-0008Nm-2V for pgsql-general@lists.postgresql.org; Tue, 21 Sep 2021 19:56:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id D3A383201F32; Tue, 21 Sep 2021 15:56:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 21 Sep 2021 15:56:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=Z hWI+0gwuYlolVyQSCi6HSLO4V6Jfzi/Mh8C0+RVWDE=; b=PZB1t4jm+mE9yTOcm vAFL3ugVcWSQqMe/mQy5Q0DFOAYoR07vh38tK3CoZG9lwfRYGKNkDw5ELWADULPO 2a355nYxYTfF7SNvklPMuDht7+YU6PnGQTrnaz7yispVGsi90GaVVlVGnB23LHp8 cnCqReIEPag1QvVQ1cPy4PbJw4wZRBViRH2KREuEslLieZ5vFrt7b9g9YEJlWMpo LltXuxDB4qdFMSDavd/CXs0xO4KxXzq/IMwWnlazZP94etluKUbCJwrHW5AsUjVi WYu+JESWfhj0UntQxlyrVpsfQ6tvPawoV4rT2wcOmaGIqzZ6AirH5V+EIYPhOkaz BTWZQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ZhWI+0gwuYlolVyQSCi6HSLO4V6Jfzi/Mh8C0+RVW DE=; b=QnmQJLMWr74Eqk+Ki4ir3TqBwzQGFd1IrByPZ/nnAGvnVD5LIVWPWJ1Cf dEPCN74FpugPGh4t6WxJl5sGU3Xgq0eWV0QM5wSkBspKS7IzKK6q/GUvCltVgTdQ 7gaCRExsy6ZdejodOCNFzu1PF66XIUZQK0CwSeUBu+/wE7L5wUN0tWSHZQ4zTwP4 J7khnCy+/5t25A4hVjyOvcRHsYb4WFQje/v7krJMTyB7+3pMlukNxjfV1w8gnwX1 uUMZXgMFfVKOPD1JuG4NccYDfDWTveiv8CHIQGf0tigwbID2ZtN9Yl/6TrA54Gft dG09WW2OIrtiXz+wIUR70szz/lqNA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeihecutefuodetggdotefrodftvfcurf hrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgrnhcu mfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqne cuggftrfgrthhtvghrnhephfdtjedvgefhvdeikeegteevlefgvdeftdeuheeiheekieff tdeuvdfgueffiefgnecuffhomhgrihhnpehfrghirhifihhnughsohhfthdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgr nhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 Sep 2021 15:56:28 -0400 (EDT) Subject: Re: Timestamp with vs without time zone. To: FWS Neil , Dave Cramer Cc: "pgsql-generallists.postgresql.org" References: <72C6EDD6-39E3-47A9-B313-A4D6C7AF0C44@fairwindsoft.com> From: Adrian Klaver Message-ID: <7af50b2b-4d51-3961-e804-b5966af46972@aklaver.com> Date: Tue, 21 Sep 2021 12:56:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <72C6EDD6-39E3-47A9-B313-A4D6C7AF0C44@fairwindsoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/21/21 11:17 AM, FWS Neil wrote: > > >> On Sep 21, 2021, at 12:34 PM, Dave Cramer > > wrote: >> On Tue, 21 Sept 2021 at 13:20, Peter J. Holzer > > wrote: >> >> 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? >> >> 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 >> >> ... 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. >> >> >> I would say this is a perspective thing. It's a timestamp with a time >> zone from the client's perspective. > > A timestamp cannot have a time zone and be a valid timestamp. > > Let me explain. > > A timestamp is a single time that exists in the world.  For example > March 1, 2021, 4:15 am is a timestamp. > > If you add a time zone (other than UTC) then a time stamp is not always > a single time that exists in the world. You have the above backwards. A time zone locks the timestamp to a single point in time. > > For example in the spring using time zone American/Chicago, on April 14, > 2021 the time zone time changes at 2am to become 3am.  The time April > 14, 2021, 2:30 am simply does not exists.  And therefore cannot be a > timestamp.  Apple’s APIs will by default automatically change 2:30am to > 3:00am.  Is that correct?  Or should it change to 3:30am?  Apple has the > option for the latter, but the APIs don’t work. In a sense it does, it becomes 3:30 am CDT. The DST change was actually 03/14/2021. An example for my timezone US/Pacific: test(5432)=# select '03/13/2021 2:30 am'::timestamptz; timestamptz ------------------------ 2021-03-13 02:30:00-08 (1 row) test(5432)=# select '03/14/2021 2:30 am'::timestamptz; timestamptz ------------------------ 2021-03-14 03:30:00-07 > > In the fall it is even worse.  Using time zone America/Chicago, on > November 7, 2021, 1:30 am occurs twice.  That does not work as a > timestamp.  Which one do you use, the early one or the late one. >  Apple’s APIs give you a choice. It occurs in two different time zones CDT then CST which makes it a different time in each case. > > The point being that people do expect to see times in local time, but > the only real timestamp is UTC and I can’t ever imagine a need to store > time zone information related to a timestamp.  If you need to store the > location that data originated from, then store the location or the Time > Zone, but it should not be connected to the timestamp.  Location data is > completely different than time data. > > Neil > www.fairwindsoft.com > > -- Adrian Klaver adrian.klaver@aklaver.com