Commit cf209e2a authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Reland "[Intl] Use new getDefaultHourCycle to replace old hack"

This reverts commit 3b1d24cf.

Reason for revert: The problem is fixed

Original change's description:
> Revert "[Intl] Use new getDefaultHourCycle to replace old hack"
> 
> This reverts commit 611e4127.
> 
> Reason for revert: https://crbug.com/1080367
> 
> Original change's description:
> > [Intl] Use new getDefaultHourCycle to replace old hack
> > 
> > Use the ICU 67.1 new API DateTimePatternGenerator::getDefaultHourCycle
> > to replace a hack which get the pattern of "jjmm" to find out the
> > default hour cycle of a locale
> > Bump the required API version from 65 to 67
> > 
> > Bug: v8:10225
> > Change-Id: I3378edacb6dfb8400357ac0bf3d5d50b9fe008bd
> > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2173875
> > Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> > Commit-Queue: Frank Tang <ftang@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#67549}
> 
> TBR=jkummerow@chromium.org,ftang@chromium.org
> 
> # Not skipping CQ checks because original CL landed > 1 day ago.
> 
> Bug: v8:10225
> Change-Id: I8bdfbdfc6c906814e5a7525cbde79c9cac854bd1
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2208811
> Reviewed-by: Zhi An Ng <zhin@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Commit-Queue: Zhi An Ng <zhin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#67929}

TBR=jkummerow@chromium.org,zhin@chromium.org,ftang@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: v8:10225
Change-Id: I386cf0347a0fa5403fb196bb46ac77f48c9c0a0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2229470Reviewed-by: 's avatarFrank Tang <ftang@chromium.org>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68165}
parent 5f9d5901
......@@ -21,7 +21,7 @@
#include "unicode/locid.h"
#include "unicode/uversion.h"
#define V8_MINIMUM_ICU_VERSION 65
#define V8_MINIMUM_ICU_VERSION 67
namespace U_ICU_NAMESPACE {
class BreakIterator;
......
......@@ -59,6 +59,21 @@ JSDateTimeFormat::HourCycle ToHourCycle(const std::string& hc) {
return JSDateTimeFormat::HourCycle::kUndefined;
}
JSDateTimeFormat::HourCycle ToHourCycle(UDateFormatHourCycle hc) {
switch (hc) {
case UDAT_HOUR_CYCLE_11:
return JSDateTimeFormat::HourCycle::kH11;
case UDAT_HOUR_CYCLE_12:
return JSDateTimeFormat::HourCycle::kH12;
case UDAT_HOUR_CYCLE_23:
return JSDateTimeFormat::HourCycle::kH23;
case UDAT_HOUR_CYCLE_24:
return JSDateTimeFormat::HourCycle::kH24;
default:
return JSDateTimeFormat::HourCycle::kUndefined;
}
}
Maybe<JSDateTimeFormat::HourCycle> GetHourCycle(Isolate* isolate,
Handle<JSReceiver> options,
const char* method) {
......@@ -1543,9 +1558,8 @@ MaybeHandle<JSDateTimeFormat> JSDateTimeFormat::New(
generator_cache.Pointer()->CreateGenerator(icu_locale));
// 15.Let hcDefault be dataLocaleData.[[hourCycle]].
icu::UnicodeString hour_pattern = generator->getBestPattern("jjmm", status);
HourCycle hc_default = ToHourCycle(generator->getDefaultHourCycle(status));
CHECK(U_SUCCESS(status));
HourCycle hc_default = HourCycleFromPattern(hour_pattern);
// 16.Let hc be r.[[hc]].
HourCycle hc = HourCycle::kUndefined;
......
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