Re: Support TZ format code in to_timestamp()

From: David Steele <david(at)pgmasters(dot)net>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Support TZ format code in to_timestamp()
Date: 2023-06-21 18:52:44
Message-ID: 0c65b54a-91a4-0812-0aa4-73a86cd3cd1a@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 6/21/23 20:07, Bruce Momjian wrote:
> On Tue, Jun 13, 2023 at 12:20:42PM -0400, Tom Lane wrote:
>> It's annoyed me for some time that to_timestamp() doesn't implement
>> the TZ format code that to_char() has. I finally got motivated to
>> do something about that after the complaint at [1] that jsonpath's
>> datetime() method can't read typical JSON.stringify() output like
>> "2023-05-22T03:09:37.825Z". We do already understand "Z" as a
>> time zone abbreviation for UTC; we just need to get formatting.c
>> to support this.
>
> I have to admit I tend to prefer actual time zone names like
> "America/New_York" over acronyms or offset values. However, I can see
> the dump/restore problem with such names.

I think the abbreviations are worse than useless -- dangerously
misleading even. I was converting a timestamp I had pulled from the
internet the other day in IST (India Standard Time) using Postres to
test some new code I was working on. I got a rather surprising result so
changed it to Asia/Kolkata and got what I expected.

Turns out IST is *also* Israel Standard Time and Irish Standard Time. I
think Postres gave me the conversion in Irish time. At any rate, it was
not offset by 30 minutes which was the dead giveaway.

Offsets are fine when you just need an absolute date to feed into
something like recovery and it doesn't much matter what timezone you
were in.

Z and UTC also seem fine since they are unambiguous as far as I know.

Regards,
-David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2023-06-21 18:54:13 Re: Memory leak in incremental sort re-scan
Previous Message Bəxtiyar Neyman 2023-06-21 18:37:24 Re: Can JoinFilter condition be pushed down into IndexScan?