File v8-icu73-alt_calendar.patch of Package nodejs-electron
From d9715adf895e9acfbaf17ae05b18f2b2467ca322 Mon Sep 17 00:00:00 2001
From: Frank Tang <ftang@chromium.org>
Date: Tue, 20 Jun 2023 15:12:47 -0700
Subject: [PATCH] [Intl] rm alt_calendar hack post ICU 73-1
Also need to bump up the required ICU version.
Bug: v8:14086
Change-Id: I52a53fcd201f3272aa712123fc00c54d0b762d53
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4628805
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#88431}
---
src/objects/intl-objects.h | 2 +-
src/objects/js-date-time-format-inl.h | 2 --
src/objects/js-date-time-format.cc | 30 +++++++--------------------
src/objects/js-date-time-format.h | 2 --
src/objects/js-date-time-format.tq | 8 -------
5 files changed, 8 insertions(+), 36 deletions(-)
diff --git a/src/objects/intl-objects.h b/src/objects/intl-objects.h
index 4339673d566..b628cf686f3 100644
--- a/v8/src/objects/intl-objects.h
+++ b/v8/src/objects/intl-objects.h
@@ -21,7 +21,7 @@
#include "unicode/locid.h"
#include "unicode/uversion.h"
-#define V8_MINIMUM_ICU_VERSION 71
+#define V8_MINIMUM_ICU_VERSION 73
namespace U_ICU_NAMESPACE {
class BreakIterator;
diff --git a/src/objects/js-date-time-format-inl.h b/src/objects/js-date-time-format-inl.h
index 8c93a8eeb63..fefe081f8f5 100644
--- a/v8/src/objects/js-date-time-format-inl.h
+++ b/v8/src/objects/js-date-time-format-inl.h
@@ -28,8 +28,6 @@ ACCESSORS(JSDateTimeFormat, icu_simple_date_format,
Tagged<Managed<icu::DateIntervalFormat>>,
kIcuDateIntervalFormatOffset)
-BOOL_ACCESSORS(JSDateTimeFormat, flags, alt_calendar, AltCalendarBit::kShift)
-
inline void JSDateTimeFormat::set_hour_cycle(HourCycle hour_cycle) {
int hints = flags();
hints = HourCycleBits::update(hints, hour_cycle);
diff --git a/src/objects/js-date-time-format.cc b/src/objects/js-date-time-format.cc
index 62d6fdcb935..6aae75c8de8 100644
--- a/v8/src/objects/js-date-time-format.cc
+++ b/v8/src/objects/js-date-time-format.cc
@@ -530,8 +530,7 @@ Handle<Object> JSDateTimeFormat::TimeZoneId(Isolate* isolate,
namespace {
Handle<String> GetCalendar(Isolate* isolate,
- const icu::SimpleDateFormat& simple_date_format,
- bool is_alt_calendar = false) {
+ const icu::SimpleDateFormat& simple_date_format) {
// getType() returns legacy calendar type name instead of LDML/BCP47 calendar
// key values. intl.js maps them to BCP47 values for key "ca".
// TODO(jshin): Consider doing it here, instead.
@@ -542,17 +541,9 @@ Handle<String> GetCalendar(Isolate* isolate,
// and
// http://www.unicode.org/repos/cldr/tags/latest/common/bcp47/calendar.xml
if (calendar_str == "gregorian") {
- if (is_alt_calendar) {
- calendar_str = "iso8601";
- } else {
- calendar_str = "gregory";
- }
+ calendar_str = "gregory";
} else if (calendar_str == "ethiopic-amete-alem") {
calendar_str = "ethioaa";
- } else if (calendar_str == "islamic") {
- if (is_alt_calendar) {
- calendar_str = "islamic-rgsa";
- }
}
return isolate->factory()->NewStringFromAsciiChecked(calendar_str.c_str());
}
@@ -567,8 +558,7 @@ Handle<Object> GetTimeZone(Isolate* isolate,
Handle<String> JSDateTimeFormat::Calendar(
Isolate* isolate, Handle<JSDateTimeFormat> date_time_format) {
return GetCalendar(isolate,
- *(date_time_format->icu_simple_date_format()->raw()),
- date_time_format->alt_calendar());
+ *(date_time_format->icu_simple_date_format()->raw()));
}
Handle<Object> JSDateTimeFormat::TimeZone(
@@ -2328,9 +2318,6 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
icu_locale.setUnicodeKeywordValue("ca", calendar_str.get(), status);
DCHECK(U_SUCCESS(status));
}
- bool alt_calendar =
- strstr(icu_locale.getName(), "calendar=iso8601") != nullptr ||
- strstr(icu_locale.getName(), "calendar=islamic-rgsa") != nullptr;
if (numbering_system_str != nullptr &&
Intl::IsValidNumberingSystem(numbering_system_str.get())) {
@@ -2640,7 +2627,6 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
date_time_format->set_time_style(time_style);
}
date_time_format->set_hour_cycle(dateTimeFormatHourCycle);
- date_time_format->set_alt_calendar(alt_calendar);
date_time_format->set_locale(*locale_str);
date_time_format->set_icu_locale(*managed_locale);
date_time_format->set_icu_simple_date_format(*managed_format);
@@ -2742,10 +2728,8 @@ MaybeHandle<JSArray> FormatToPartsWithTemporalSupport(
DateTimeValueRecord x_record;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, x_record,
- HandleDateTimeValue(
- isolate, *format,
- GetCalendar(isolate, *format, date_time_format->alt_calendar()), x,
- method_name),
+ HandleDateTimeValue(isolate, *format, GetCalendar(isolate, *format), x,
+ method_name),
Handle<JSArray>());
return FormatMillisecondsByKindToArray(isolate, *format, x_record.kind,
@@ -3070,8 +3054,8 @@ MaybeHandle<T> FormatRangeCommonWithTemporalSupport(
// 6. Let x be ? HandleDateTimeValue(dateTimeFormat, x).
icu::SimpleDateFormat* icu_simple_date_format =
date_time_format->icu_simple_date_format()->raw();
- Handle<String> date_time_format_calendar = GetCalendar(
- isolate, *icu_simple_date_format, date_time_format->alt_calendar());
+ Handle<String> date_time_format_calendar =
+ GetCalendar(isolate, *icu_simple_date_format);
DateTimeValueRecord x_record;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, x_record,
diff --git a/src/objects/js-date-time-format.h b/src/objects/js-date-time-format.h
index cdf87c2268a..ceebcc5e8f9 100644
--- a/v8/src/objects/js-date-time-format.h
+++ b/v8/src/objects/js-date-time-format.h
@@ -150,8 +150,6 @@ class JSDateTimeFormat
DECL_ACCESSORS(icu_simple_date_format, Managed<icu::SimpleDateFormat>)
DECL_ACCESSORS(icu_date_interval_format, Managed<icu::DateIntervalFormat>)
- DECL_BOOLEAN_ACCESSORS(alt_calendar)
-
DECL_PRINTER(JSDateTimeFormat)
TQ_OBJECT_CONSTRUCTORS(JSDateTimeFormat)
diff --git a/src/objects/js-date-time-format.tq b/src/objects/js-date-time-format.tq
index ef0584e7901..6fab20c71d1 100644
--- a/v8/src/objects/js-date-time-format.tq
+++ b/v8/src/objects/js-date-time-format.tq
@@ -10,14 +10,6 @@ bitfield struct JSDateTimeFormatFlags extends uint31 {
hour_cycle: HourCycle: 3 bit;
date_style: DateTimeStyle: 3 bit;
time_style: DateTimeStyle: 3 bit;
- // ICU report the same type "gregorian" for both "gregorian" calendar and
- // "iso8601" calendar and the same type "islamic" for both "islamic" and
- // "islamic-rgsa" calendar. We use the alt_calendar bit to distinguish between
- // them. When the type is "gregorian" and the alt_calendar bit is set, it is
- // "iso8601", otherwise the true "gregorian" calendar. While the type is
- // "islamic" and the alt_calendar bit is set, it is "islamic-rgsa" calendar,
- // otherwise "islamic" calendar.
- alt_calendar: bool: 1bit;
}
extern class JSDateTimeFormat extends JSObject {