Diff
Modified: trunk/JSTests/ChangeLog (281370 => 281371)
--- trunk/JSTests/ChangeLog 2021-08-21 12:28:04 UTC (rev 281370)
+++ trunk/JSTests/ChangeLog 2021-08-21 13:02:32 UTC (rev 281371)
@@ -1,5 +1,17 @@
2021-08-21 Yusuke Suzuki <ysuz...@apple.com>
+ [JSC] Extend Intl TimeZoneName Option
+ https://bugs.webkit.org/show_bug.cgi?id=227831
+
+ Reviewed by Ross Kirsling.
+
+ * stress/intl-extended-timezone-names.js: Added.
+ (shouldBe):
+ (timeZoneTest):
+ * test262/config.yaml:
+
+2021-08-21 Yusuke Suzuki <ysuz...@apple.com>
+
[JSC] Enable Array#findLast method
https://bugs.webkit.org/show_bug.cgi?id=229355
Added: trunk/JSTests/stress/intl-extended-timezone-names.js (0 => 281371)
--- trunk/JSTests/stress/intl-extended-timezone-names.js (rev 0)
+++ trunk/JSTests/stress/intl-extended-timezone-names.js 2021-08-21 13:02:32 UTC (rev 281371)
@@ -0,0 +1,75 @@
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error("bad value: " + actual);
+}
+
+let timeZoneNames = ["short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"];
+let date = new Date(1625939282389);
+
+function timeZoneTest(date, locale, expectedSet, timeZone = "America/Los_Angeles")
+{
+ timeZoneNames.forEach(function(timeZoneName) {
+ let formatter = new Intl.DateTimeFormat(locale, {
+ year: "numeric",
+ month: "numeric",
+ day: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ second: "2-digit",
+ timeZone,
+ timeZoneName
+ });
+ let actual = formatter.format(date);
+ // print(`${timeZoneName}: "${actual}",`);
+ let expected = expectedSet[timeZoneName];
+ if (Array.isArray(expected))
+ shouldBe(expected.includes(actual), true);
+ else
+ shouldBe(actual, expected);
+ });
+}
+
+timeZoneTest(date, "en", {
+ short: "7/10/2021, 10:48:02 AM PDT",
+ long: "7/10/2021, 10:48:02 AM Pacific Daylight Time",
+ shortOffset: "7/10/2021, 10:48:02 AM GMT-7",
+ longOffset: "7/10/2021, 10:48:02 AM GMT-07:00",
+ shortGeneric: "7/10/2021, 10:48:02 AM PT",
+ longGeneric: "7/10/2021, 10:48:02 AM Pacific Time",
+});
+
+timeZoneTest(date, "en", {
+ short: "7/10/2021, 11:18:02 PM GMT+5:30",
+ long: "7/10/2021, 11:18:02 PM India Standard Time",
+ shortOffset: "7/10/2021, 11:18:02 PM GMT+5:30",
+ longOffset: "7/10/2021, 11:18:02 PM GMT+05:30",
+ shortGeneric: "7/10/2021, 11:18:02 PM India Time",
+ longGeneric: "7/10/2021, 11:18:02 PM India Standard Time",
+}, "Asia/Calcutta");
+
+timeZoneTest(date, "zh-Hant", {
+ short: ["2021/7/10 PDT 上午10:48:02", "2021/7/10 上午10:48:02 [PDT]"],
+ long: ["2021/7/10 太平洋夏令時間 上午10:48:02", "2021/7/10 上午10:48:02 [太平洋夏令時間]"],
+ shortOffset: ["2021/7/10 GMT-7 上午10:48:02", "2021/7/10 上午10:48:02 [GMT-7]"],
+ longOffset: ["2021/7/10 GMT-07:00 上午10:48:02", "2021/7/10 上午10:48:02 [GMT-07:00]"],
+ shortGeneric: ["2021/7/10 PT 上午10:48:02", "2021/7/10 上午10:48:02 [PT]"],
+ longGeneric: ["2021/7/10 太平洋時間 上午10:48:02", "2021/7/10 上午10:48:02 [太平洋時間]"],
+});
+
+timeZoneTest(date, "ja-JP", {
+ short: "2021/7/10 10:48:02 GMT-7",
+ long: "2021/7/10 10時48分02秒 アメリカ太平洋夏時間",
+ shortOffset: "2021/7/10 10時48分02秒 GMT-7",
+ longOffset: "2021/7/10 10時48分02秒 GMT-07:00",
+ shortGeneric: "2021/7/10 10:48:02 ロサンゼルス時間",
+ longGeneric: "2021/7/10 10:48:02 アメリカ太平洋時間",
+});
+
+timeZoneTest(date, "ja-JP", {
+ short: "2021/7/11 02:48:02 JST",
+ long: "2021/7/11 02時48分02秒 日本標準時",
+ shortOffset: "2021/7/11 02時48分02秒 GMT+9",
+ longOffset: "2021/7/11 02時48分02秒 GMT+09:00",
+ shortGeneric: "2021/7/11 02:48:02 JST",
+ longGeneric: "2021/7/11 02:48:02 日本標準時",
+}, "Asia/Tokyo");
Modified: trunk/JSTests/test262/config.yaml (281370 => 281371)
--- trunk/JSTests/test262/config.yaml 2021-08-21 12:28:04 UTC (rev 281370)
+++ trunk/JSTests/test262/config.yaml 2021-08-21 13:02:32 UTC (rev 281371)
@@ -32,7 +32,6 @@
- json-modules
- class-static-block
- Intl.DisplayNames-v2
- - Intl.DateTimeFormat-extend-timezonename
- callable-boundary-realms
paths:
files:
Modified: trunk/Source/_javascript_Core/ChangeLog (281370 => 281371)
--- trunk/Source/_javascript_Core/ChangeLog 2021-08-21 12:28:04 UTC (rev 281370)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-08-21 13:02:32 UTC (rev 281371)
@@ -1,5 +1,23 @@
2021-08-21 Yusuke Suzuki <ysuz...@apple.com>
+ [JSC] Extend Intl TimeZoneName Option
+ https://bugs.webkit.org/show_bug.cgi?id=227831
+
+ Reviewed by Ross Kirsling.
+
+ https://github.com/tc39/proposal-intl-extend-timezonename
+
+ This patch implements Extend Intl TimeZoneName proposal, which adds "shortOffset", "longOffset", "shortGeneric", "longGeneric"
+ timeZoneName variants.
+
+ * runtime/IntlDateTimeFormat.cpp:
+ (JSC::IntlDateTimeFormat::setFormatsFromPattern):
+ (JSC::IntlDateTimeFormat::initializeDateTimeFormat):
+ (JSC::IntlDateTimeFormat::timeZoneNameString):
+ * runtime/IntlDateTimeFormat.h:
+
+2021-08-21 Yusuke Suzuki <ysuz...@apple.com>
+
[JSC] Enable String,TypedArray#at
https://bugs.webkit.org/show_bug.cgi?id=229354
Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (281370 => 281371)
--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp 2021-08-21 12:28:04 UTC (rev 281370)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp 2021-08-21 13:02:32 UTC (rev 281371)
@@ -411,13 +411,24 @@
m_second = Second::TwoDigit;
break;
case 'z':
- case 'v':
- case 'V':
if (count == 1)
m_timeZoneName = TimeZoneName::Short;
else if (count == 4)
m_timeZoneName = TimeZoneName::Long;
break;
+ case 'O':
+ if (count == 1)
+ m_timeZoneName = TimeZoneName::ShortOffset;
+ else if (count == 4)
+ m_timeZoneName = TimeZoneName::LongOffset;
+ break;
+ case 'v':
+ case 'V':
+ if (count == 1)
+ m_timeZoneName = TimeZoneName::ShortGeneric;
+ else if (count == 4)
+ m_timeZoneName = TimeZoneName::LongGeneric;
+ break;
case 'S':
m_fractionalSecondDigits = count;
break;
@@ -789,7 +800,7 @@
for (unsigned i = 0; i < fractionalSecondDigits; ++i)
skeletonBuilder.append('S');
- TimeZoneName timeZoneName = intlOption<TimeZoneName>(globalObject, options, vm.propertyNames->timeZoneName, { { "short"_s, TimeZoneName::Short }, { "long"_s, TimeZoneName::Long } }, "timeZoneName must be \"short\" or \"long\""_s, TimeZoneName::None);
+ TimeZoneName timeZoneName = intlOption<TimeZoneName>(globalObject, options, vm.propertyNames->timeZoneName, { { "short"_s, TimeZoneName::Short }, { "long"_s, TimeZoneName::Long }, { "shortOffset"_s, TimeZoneName::ShortOffset }, { "longOffset"_s, TimeZoneName::LongOffset }, { "shortGeneric"_s, TimeZoneName::ShortGeneric}, { "longGeneric"_s, TimeZoneName::LongGeneric } }, "timeZoneName must be \"short\", \"long\", \"shortOffset\", \"longOffset\", \"shortGenric\", or \"longGeneric\""_s, TimeZoneName::None);
RETURN_IF_EXCEPTION(scope, void());
switch (timeZoneName) {
case TimeZoneName::Short:
@@ -798,6 +809,18 @@
case TimeZoneName::Long:
skeletonBuilder.append("zzzz");
break;
+ case TimeZoneName::ShortOffset:
+ skeletonBuilder.append('O');
+ break;
+ case TimeZoneName::LongOffset:
+ skeletonBuilder.append("OOOO");
+ break;
+ case TimeZoneName::ShortGeneric:
+ skeletonBuilder.append('v');
+ break;
+ case TimeZoneName::LongGeneric:
+ skeletonBuilder.append("vvvv");
+ break;
case TimeZoneName::None:
break;
}
@@ -1100,6 +1123,14 @@
return "short"_s;
case TimeZoneName::Long:
return "long"_s;
+ case TimeZoneName::ShortOffset:
+ return "shortOffset"_s;
+ case TimeZoneName::LongOffset:
+ return "longOffset"_s;
+ case TimeZoneName::ShortGeneric:
+ return "shortGeneric"_s;
+ case TimeZoneName::LongGeneric:
+ return "longGeneric"_s;
case TimeZoneName::None:
ASSERT_NOT_REACHED();
return ASCIILiteral::null();
Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.h (281370 => 281371)
--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.h 2021-08-21 12:28:04 UTC (rev 281370)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.h 2021-08-21 13:02:32 UTC (rev 281371)
@@ -102,7 +102,7 @@
enum class Hour : uint8_t { None, TwoDigit, Numeric };
enum class Minute : uint8_t { None, TwoDigit, Numeric };
enum class Second : uint8_t { None, TwoDigit, Numeric };
- enum class TimeZoneName : uint8_t { None, Short, Long };
+ enum class TimeZoneName : uint8_t { None, Short, Long, ShortOffset, LongOffset, ShortGeneric, LongGeneric };
enum class DateTimeStyle : uint8_t { None, Full, Long, Medium, Short };
void setFormatsFromPattern(const StringView&);