[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}
This commit is contained in:
parent
1faa8c8be4
commit
611e412768
@ -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;
|
||||
|
@ -42,6 +42,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) {
|
||||
@ -1518,9 +1533,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;
|
||||
|
Loading…
Reference in New Issue
Block a user