index d79c9298227a064740764a2581322991d9aea3da..c47221b7ee77eb0d6e465f7bee9c32089109d82a 100644 (file)
@@ -2707,12 +2707,27 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
break;
case jpiTimestampTz:
{
+ struct pg_tm tm;
+ fsec_t fsec;
+
/* Convert result type to timestamp with time zone */
switch (typid)
{
case DATEOID:
checkTimezoneIsUsedForCast(cxt->useTz,
"date", "timestamptz");
+
+ /*
+ * Get the timezone value explicitly since JsonbValue
+ * keeps that separate.
+ */
+ j2date(DatumGetDateADT(value) + POSTGRES_EPOCH_JDATE,
+ &(tm.tm_year), &(tm.tm_mon), &(tm.tm_mday));
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ tz = DetermineTimeZoneOffset(&tm, session_timezone);
+
value = DirectFunctionCall1(date_timestamptz,
value);
break;
@@ -2726,6 +2741,16 @@ executeDateTimeMethod(JsonPathExecContext *cxt, JsonPathItem *jsp,
case TIMESTAMPOID:
checkTimezoneIsUsedForCast(cxt->useTz,
"timestamp", "timestamptz");
+
+ /*
+ * Get the timezone value explicitly since JsonbValue
+ * keeps that separate.
+ */
+ if (timestamp2tm(DatumGetTimestamp(value), NULL, &tm,
+ &fsec, NULL, NULL) == 0)
+ tz = DetermineTimeZoneOffset(&tm,
+ session_timezone);
+
value = DirectFunctionCall1(timestamp_timestamptz,
value);
break;
index 7bb4eb1bc276ef0bff04836e115ba359bc5dbd60..02abaac68912c7105cc0fffa8b605b9b31ddae8d 100644 (file)
@@ -2964,7 +2964,7 @@ HINT: Use *_tz() function for time zone support.
select jsonb_path_query_tz('"2023年08月15日"', '$.timestamp_tz()'); -- should work
jsonb_path_query_tz
-----------------------------
- "2023年08月15日T07:00:00+00:00"
+ "2023年08月15日T00:00:00-07:00"
(1 row)
select jsonb_path_query('"12:34:56"', '$.timestamp_tz()');
@@ -3151,7 +3151,7 @@ HINT: Use *_tz() function for time zone support.
select jsonb_path_query_tz('"2023年08月15日 12:34:56"', '$.timestamp_tz()'); -- should work
jsonb_path_query_tz
-----------------------------
- "2023年08月15日T02:34:56+00:00"
+ "2023年08月15日T12:34:56+10:00"
(1 row)
select jsonb_path_query('"2023年08月15日 12:34:56 +05:30"', '$.timestamp_tz()');