Commit 4c1e09a4 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

[Intl] Only set HourCycle if needed

* Change the logic to reflect the spec change of
  https://github.com/tc39/proposal-intl-datetime-style/pull/37/
* Move enum value of kUndefined to 0 to make unset behavior the same as
  kUndefined.
* Change the expectation of existing tests
* Additional tests - https://github.com/tc39/test262/pull/2385

Bug: v8:9826
Change-Id: Ic437b5f6414aa641ae73766d8c5fd5b9d352a230
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1846722Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64255}
parent a2cf9790
......@@ -240,14 +240,14 @@ class Intl {
Handle<JSFunction> constructor, bool has_initialized_slot);
// enum for "caseFirst" option: shared by Intl.Locale and Intl.Collator.
enum class CaseFirst { kUpper, kLower, kFalse, kUndefined };
enum class CaseFirst { kUndefined, kUpper, kLower, kFalse };
// Shared function to read the "caseFirst" option.
V8_WARN_UNUSED_RESULT static Maybe<CaseFirst> GetCaseFirst(
Isolate* isolate, Handle<JSReceiver> options, const char* method);
// enum for "hourCycle" option: shared by Intl.Locale and Intl.DateTimeFormat.
enum class HourCycle { kH11, kH12, kH23, kH24, kUndefined };
enum class HourCycle { kUndefined, kH11, kH12, kH23, kH24 };
static HourCycle ToHourCycle(const std::string& str);
......
......@@ -1546,12 +1546,16 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
isolate->factory()->NewFastOrSlowJSObjectFromMap(map));
DisallowHeapAllocation no_gc;
date_time_format->set_flags(0);
date_time_format->set_hour_cycle(hc);
if (date_style != DateTimeStyle::kUndefined) {
date_time_format->set_date_style(date_style);
}
if (time_style != DateTimeStyle::kUndefined) {
date_time_format->set_time_style(time_style);
date_time_format->set_hour_cycle(hc);
}
if ((date_style == DateTimeStyle::kUndefined) &&
(time_style == DateTimeStyle::kUndefined)) {
date_time_format->set_hour_cycle(hc);
}
date_time_format->set_icu_locale(*managed_locale);
date_time_format->set_icu_simple_date_format(*managed_format);
......
......@@ -32,8 +32,6 @@ var expectedProperties = [
'calendar',
'numberingSystem',
'timeZone',
'hourCycle',
'hour12',
'dateStyle',
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment