GMT 时间戳的固定偏移规范

fixed offset specifications of a GMT timestamp

我的数据以格林威治标准时间 (GMT) 的时间戳存储:

import pandas as pd
import pytz

# data is stored in UTC 
timestamp_utc = pd.Timestamp('2018-1-18 23:00', tz='Etc/GMT')
print(timestamp_utc)
2018-01-18 23:00:00+00:00

现在我想查看中欧时间 (CET) 中的数据,该时间与格林威治标准时间固定偏移 +1 小时。

# Central European Time (CET)
cet_tz = pytz.timezone('Etc/GMT+1')

timestamp_cet = timestamp_utc.astimezone(cet_tz)
print(timestamp_cet)
2018-01-18 22:00:00-01:00

这让我很困惑,我本以为 2018-01-19 00:00:00+01:00

documentation 中提到了固定偏移量:

Fixed offsets

The 'Etc/GMT*' time zones mentioned above provide fixed offset specifications, but watch out for the counter-intuitive sign convention.

谁能解释一下这是什么意思?这真的意味着,如果我想要 Etc/GMT+1 我必须做 Etc/GMT-1 吗?

开始于:

print(timestamp_utc.astimezone(pytz.timezone('Etc/GMT-1')))

预期结果:

2018-01-19 00:00:00+01:00

谁能解释这种违反直觉的行为的逻辑?

编辑

我想我可以使用 pytz.timezone('CET') 作为欧洲中部时间。但这在夏季夏令时 (UTC+2:00) 期间映射到 CEST,因此不适合用作真正的 CET 时区。此外,时区 CET 也是 deprecated.

因此,Etc/GMT-1 是表示真正中欧时间 (UTC+01:00) 的规范方式。

Etc/GMT* 时区设计为 POSIX 兼容,以便在未安装完整时区数据库的系统上向后兼容 TZ 环境变量。 POSIX 时区规则的偏移符号与我们通常期望的 ISO 8601 标准相反。

这在评论中有解释 in the tz database:

Be consistent with POSIX TZ settings in the Zone names, even though this is the opposite of what many people expect. POSIX has positive signs west of Greenwich, but many people expect positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses the abbreviation "-04" and corresponds to 4 hours behind UT (i.e. west of Greenwich) even though many people would expect it to mean 4 hours ahead of UT (i.e. east of Greenwich).

也有描述on Wikipedia:

The special area of "Etc" is used for some administrative zones, particularly for "Etc/UTC" which represents Coordinated Universal Time. In order to conform with the POSIX style, those zone names beginning with "Etc/GMT" have their sign reversed from the standard ISO 8601 convention. In the "Etc" area, zones west of GMT have a positive sign and those east have a negative sign in their name (e.g "Etc/GMT-14" is 14 hours ahead of GMT.)

一般来说,对于陆地上有人居住的地点,您应该更喜欢使用基于位置的区域标识符。例如,使用 Europe/Amsterdam 表示荷兰的时间。这具有在正确的时间点以及任何先前的历史转换之间正确切换 CET 和 CEST 的优势。

使用 Etc/GMT* 区域预留边缘情况,例如海上船舶的跟踪时间。

您可以查看 tzdb 区域名称的完整列表 here