FireFox 是否支持 Date.prototype.toLocaleString() 中的 IANA 时区?

Does FireFox support IANA time zones in Date.prototype.toLocaleString()?

在执行以下代码时,我 运行 在 FireFox 38.0.1(在撰写本文时全新安装了最新版本)中遇到了一个令人惊讶的异常:

var d = new Date()
var formattingOptions = { timeZone: 'America/New_York', month: '2-digit', day: '2-digit', year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
var formattedDate = d.toLocaleString('en-US', formattingOptions);

显然,FireFox 不喜欢我使用 formattingOptions.timeZone,并这样回应:RangeError: invalid time zone in DateTimeFormat(): AMERICA/NEW_YORK

FireFox 是否在其日期格式化方法(例如 Date.prototype.toLocaleString、Intl.DateTimeFormat 等)的实现中不支持 IANA 时区?

请注意,ECMA-402 使 IANA 时区成为一个纯粹的可选要求。看来 Firefox 目前还没有选择支持它们。

默认行为是拒绝 12.1.1.1UTC 以外的任何 timeZone 值:

  1. Let tz be the result of calling the [[Get]] internal method of options with argument "timeZone".
  2. If tz is not undefined, then
    • a. Let tz be ToString(tz).
    • b. Convert tz to upper case as described in 6.1.
      NOTE: If an implementation accepts additional time zone values, as permitted under certain conditions by the Conformance clause, different casing rules apply.
    • c. If tz is not "UTC", then throw a RangeError exception.

但是,如注释中所述,除 UTC 之外的其他值可能 受支持:

A conforming implementation is permitted to accept additional values, and then have implementation-defined behaviour instead of throwing a RangeError, for the following properties of options arguments:

[...]

The options property timeZone in the DateTimeFormat constructor, provided that the additional acceptable input values are case-insensitive matches of Zone or Link identifiers in the IANA time zone database and are canonicalized to Zone identifiers in the casing used in the database for the timeZone property of the object returned by DateTimeFormat.resolvedOptions, except that "Etc/GMT" shall be canonicalized to "UTC".

如果我们查看 /js/src/builtin/Intl.js 中的 InitializeDateTimeFormat,我们会看到来自 ECMA-402 12.1.1.1 的这些步骤的实现:

 // Steps 15-17.
 var tz = options.timeZone;
 if (tz !== undefined) {
     tz = toASCIIUpperCase(ToString(tz));
     if (tz !== "UTC")
         ThrowRangeError(JSMSG_INVALID_TIME_ZONE, tz);
 }

显然,这会拒绝 UTC 以外的任何 timeZone 值,因此我认为我们可以有把握地得出结论,Firefox 的 toLocaleString 尚不支持 IANA 时区。