在 PostgreSQL 中,时区偏移量使用错误的符号

In PostgreSQL timezone offset is taken with the wrong sign

我正在试验 PostgreSQL TIME 数据类型,我注意到一个奇怪的行为。

test=# SELECT CURRENT_TIME;
current_time
--------------------
08:43:35.446737+00
(1 row)

test=# SELECT CURRENT_TIME  AT TIME ZONE '+04';
timezone
--------------------
04:43:50.475164-04
(1 row)

test=# SELECT CURRENT_TIME  AT TIME ZONE '-04';
  timezone
--------------------
12:43:54.810124+04
(1 row)

如您所见,默认时区是 00,因此当我将其转换为 +04 时,我希望得到结果我用 -04

转换它时得到的

是否有人熟悉此行为背后的原因或者这是一个错误

您正在使用 POSIX 风格的时区名称,这有点奇怪。来自 the docs

Another issue to keep in mind is that in POSIX time zone names, positive offsets are used for locations west of Greenwich. Everywhere else, PostgreSQL follows the ISO-8601 convention that positive timezone offsets are east of Greenwich.

此外,来自相同的文档:

We do not recommend using the type time with time zone (though it is supported by PostgreSQL for legacy applications and for compliance with the SQL standard).