From: | Junwang Zhao <zhjwpku(at)gmail(dot)com> |
---|---|
To: | "David E(dot) Wheeler" <david(at)justatheory(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: jsonpath: Inconsistency of timestamp_tz() Output |
Date: | 2024-07-09 15:08:52 |
Message-ID: | CAEG8a3+QHYaLk+g8_LDnpbPMEC-Ht7-mOV2OsvTqqCmbWWJhew@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, Jul 9, 2024 at 10:22 PM David E. Wheeler <david(at)justatheory(dot)com> wrote:
>
> On Jul 9, 2024, at 10:07, David E. Wheeler <david(at)justatheory(dot)com> wrote:
>
> > So perhaps I had things reversed before. Maybe it’s actually doing the right then when it converts a timestamp to a timestamptz, but not when it the input contains an offset, as in your example.
>
> To clarify, there’s an inconsistency in the output of timestamp_tz() depending on whether the input has an offset or not. With offset:
>
> david=# select jsonb_path_query_tz('"2024-08-15 12:34:56-05"', '$.timestamp_tz()');
> jsonb_path_query_tz
> -----------------------------
> "2024-08-15T12:34:56-05:00"
>
> And without:
>
> david=# select jsonb_path_query_tz('"2024-08-15 12:34:56"', '$.timestamp_tz()');
> jsonb_path_query_tz
> -----------------------------
> "2024-08-15T16:34:56+00:00"
>
> I suspect the latter is correct, given that the timestamptz type appears to be an int64, presumably always in UTC. I don’t understand where the first example stores the offset.
In JsonbValue.val.datatime, there is a tz field, I think that's where
the offset stored, it is 18000 in the first example
struct
{
Datum value;
Oid typid;
int32 typmod;
int tz; /* Numeric time zone, in seconds, for
* TimestampTz data type */
} datetime;
>
> Best,
>
> David
>
>
>
--
Regards
Junwang Zhao
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-07-09 15:31:22 | Re: array_in sub function ReadArrayDimensions error message |
Previous Message | Jeremy Schneider | 2024-07-09 14:51:39 | Re: Built-in CTYPE provider |