节点的 Date.parse 支持什么时区别名?

What time zone aliases does node's Date.parse support?

虽然节点的 Date.parse 处理数字时区,如 Date.parse('2015-01-01 00:00 UTC-7'),但它也处理一些别名,如太平洋标准时间的 PST。完整列表是什么?

我不确定它在哪里定义,但在三个字母的 ASCII 命名空间中进行了详尽的搜索:

alphabet = []
a = 'A'
while a <= 'Z'
  alphabet.push a
  a = String.fromCharCode a.charCodeAt() + 1

months = 'JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC'.split ','
tzs = {}

for a in alphabet
  for b in alphabet
    for c in alphabet
      tz = a + b + c
      continue  if tz in months
      try
        t = Date.parse '2015-01-01 00:00:00 ' + tz
        tzs[tz] = (new Date t).toISOString()
        console.log tz, tzs[tz]

...表明它只是一些美国的,UTC/GMT:

CDT 2015-01-01T05:00:00.000Z
CST 2015-01-01T06:00:00.000Z
EDT 2015-01-01T04:00:00.000Z
EST 2015-01-01T05:00:00.000Z
GMT 2015-01-01T00:00:00.000Z
MDT 2015-01-01T06:00:00.000Z
MST 2015-01-01T07:00:00.000Z
PDT 2015-01-01T07:00:00.000Z
PST 2015-01-01T08:00:00.000Z
UTC 2015-01-01T00:00:00.000Z

它支持与 RFC822 (superseded by RFC2822 and RFC5322)

兼容所需的区域
 zone        =  "UT"  / "GMT"                ; Universal Time
                                             ; North American : UT
             /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
             /  "CST" / "CDT"                ;  Central:  - 6/ - 5
             /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
             /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7

它还支持 "Z",因为它是 ISO8601 (and mandated by ES5.1§15.9.1.15) 的一部分)和 "UTC",因为它是一个非常常见的约定(尽管很有趣,但不在规范中!)

请注意,RFC822 还描述了其他军事时区缩写,从 AZ,但仅支持 Z。其他的已从大多数实现中弃用。

另请注意,时区缩写通常不可靠。具体来说,考虑一下虽然 "CST" 在这里定义为 UTC-6,但它可能是世界上恰好共享相同的三个字母缩写的 5 个不同时区之一。参见 this list on Wikipedia