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 1tcWJw-000gkv-Er for pgsql-general@arkaria.postgresql.org; Mon, 27 Jan 2025 21:07:00 +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 1tcWJv-00Eieb-EG for pgsql-general@arkaria.postgresql.org; Mon, 27 Jan 2025 21:06:59 +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 1tcWJv-00EieQ-3K for pgsql-general@lists.postgresql.org; Mon, 27 Jan 2025 21:06:59 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tcWJk-001pCY-36 for pgsql-general@postgresql.org; Mon, 27 Jan 2025 21:06:58 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 7B7841380B0D; Mon, 27 Jan 2025 16:06:48 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 27 Jan 2025 16:06:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1738012008; x=1738098408; bh=LMx4Sw2QYab3S84tVn5if3OW4eZU+lWZzfxR1j9+wHQ=; b= nPwBpFEv4jkuotnqz3BVVyGLAEEHppeeRXdMKNL/7XD1e+eRwjBQmwCZJ+CmQhn+ AVpnx1vspvHO1tsAzkaxU/XcS5AwHNwuzmm3vzWgwykfJfcnxLOm2QQlt4aIq3ul 7MUUPMtXH5p/PQ7/DuTOezTe1/uacuUMly9VpA6xvKCjYeXiVdgqnnk5mOGYrN2N UxZcmcfdsu9n11qq5CZTXti14nAO49ssF9s2ZyulbmC9TNIddLXAXweuvNXXWrwf 5g6EHymqF1eIWmXdVodonmYyE8FUEWIsY1EPL1kuhvdGqJVCFoLbzlBr4GoSUEFe XwiWHbiD8iN2jOtMM50Nnw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1738012008; x=1738098408; bh=L Mx4Sw2QYab3S84tVn5if3OW4eZU+lWZzfxR1j9+wHQ=; b=goVPY51p6UrIzPqHW dyEMG/SCwKjuuLyvFWgi7f36+VgqcLCZURAPI87SzNpV0HyyXFoY481og8pHes/i /MOL46HacjF7+Wy/3Hi0DjahQ5eVJ1lwndEXUJbqhtIZuICLAmwQf1tm7JNEpe3d r2+G/8mY7cuYOw9aK4uytlf4VQbmZ5C9wml1BVY7GaK+Lj4Y+o08NUK9lJLpEQfy mSvQlCI3afeaRMjPv8pRzHOmaAw2Qn2FpLK8OyVw5tA0N4Cmm2xNBVecVzQ0EFlO 4c+Kpci10c+IhK5cSmu53wdyWOTMy3GIIPp2XHXvbLLbud4UGn/eXQFTGY68ioqZ J6a0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudejgedgudegvddvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefkff ggfgfuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghv vghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrf grthhtvghrnhepjeefvdduteejvdeltdetveefvddvjeehffeiveevhfetveegteettdfg vdffleehnecuffhomhgrihhnpeifihhkihhpvgguihgrrdhorhhgpdgusghfihguughlvg druhhkpdhpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvg hrrdgtohhmpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphht thhopegvlhhlvghnrghllhhhrghtrghtlhgrnhesghhmrghilhdrtghomhdprhgtphhtth hopehpghhsqhhlqdhgvghnvghrrghlsehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 27 Jan 2025 16:06:47 -0500 (EST) Message-ID: <5c09e4b5-1b00-41e6-a56c-ce1c10a3f1de@aklaver.com> Date: Mon, 27 Jan 2025 13:06:47 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Issues with EPOCH-s, TIMESTAMP(TZ)-s and leap seconds. To: Nem Tudom , pgsql-general References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/27/25 13:01, Nem Tudom wrote: > > > Hi all, > > > I'm having trouble understanding matters related to TIMESTAMP(TZ)-s and > leap seconds - my machine runs on UTC so as to remove any issues related > to the zones. > > From here: https://en.wikipedia.org/wiki/Leap_second, > > There have been 27 leap seconds added to UTC since 1972. > > > But, when I run this fiddle (see bottom of this email link) > > https://dbfiddle.uk/wxvmzfJb > > (first snippet - 2015 -> 2016) I get a "nice" even number for the EPOCH > of, 00:00:00 2016 , say (= 1451606400) - now, with 27 leap seconds since > 1972, I would expect that number to be (something like) 1451606427? > > I thought that the EPOCH was the number of seconds since 1970-01-01 > 00:00:00? Is this incorrect? > > Also, (first snippet again), why is the TIMESTAMPTZ 23:59:60 2015 even > allowed? > > Now, we come to the second snippet (2016 -> 2017), I get *_exactly_* the > same behaviour! > > I was expecting to see that '2016-12-31 23:59:60'::TIMESTAMPTZ would > work (leap second) and then that '2017-01-01 00:00:00'::TIMESTAMPTZ > would have incremented by 1 second? > > I'm puzzled. Does PostgreSQL take leap seconds into account? Does anyone? > > Any help, advice, recommendations, URL-s, references &c. appreciated. https://www.postgresql.org/docs/current/functions-datetime.html "timezone The time zone offset from UTC, measured in seconds. Positive values correspond to time zones east of UTC, negative values to zones west of UTC. (Technically, PostgreSQL does not use UTC because leap seconds are not handled.) " https://www.postgresql.org/docs/current/view-pg-timezone-names.html " (Technically, PostgreSQL does not use UTC because leap seconds are not handled.)" > > > E... > > > > > -- Adrian Klaver adrian.klaver@aklaver.com