PostgreSQL 中的时区转换不一致

Inconsistent time zone conversion in PostgreSQL

我正在尝试从 PostgreSQL 数据库中的 timestamptz 字段 select 当地时间(截至 Australia/Brisbane),并注意到当我使用 +10 时区缩写,PostgreSQL 似乎从 UTC 值中减去 10 小时,而不是增加 10 小时。

如果我使用 AEST 作为缩写,则正确添加 10 小时。

当我 运行 以下查询时,我希望返回的两个值相同。

select 
  ('2018-01-01T00:00:00Z'::timestamp with time zone) at time zone 'AEST', 
  ('2018-01-01T00:00:00Z'::timestamp with time zone) at time zone '+10';

但是,就我而言,我看到了以下结果:

"2018-01-01 10:00:00"   | "2017-12-31 14:00:00"

如果我 运行 以下查询,所有行的 "utc_offset" 间隔为 10:00:00。

select * from pg_timezone_names
where abbrev in ('+10', 'AEST')

谁能解释一下这是怎么回事?

这实际上在 the documentation 中有一些详细的描述:

PostgreSQL allows you to specify time zones in three different forms:

  • A full time zone name, for example America/New_York. [...]

  • A time zone abbreviation, for example PST. [...]

  • In addition to the timezone names and abbreviations, PostgreSQL will accept POSIX-style time zone specifications of the form <em>STDoffset</em> or <em>STDoffsetDST</em>, where <em>STD</em> is a zone abbreviation, <em>offset</em> is a numeric offset in hours west from UTC, and <em>DST</em> is an optional daylight-savings zone abbreviation, assumed to stand for one hour ahead of the given offset. [...]

[...]

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.

因此 AEST 的 POSIX 等价于 -10UTC-10