mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
按照ecma标准修改方舟JSDateTimeFormat::InitializeDateTimeFormat
Signed-off-by: yanpeng <yanpeng51@huawei.com> Change-Id: Iba732e8d876bcd0ce629cbc12a8b20f4700476aa
This commit is contained in:
parent
8602729bf8
commit
1c034a62bc
@ -511,10 +511,17 @@ JSHandle<JSDateTimeFormat> JSDateTimeFormat::InitializeDateTimeFormat(JSThread *
|
||||
for (const IcuPatternDesc &item : data) {
|
||||
// prop be [[TimeZoneName]]
|
||||
if (item.property == "timeZoneName") {
|
||||
// b. If prop is "fractionalSecondDigits", then
|
||||
// i. Let value be ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined).
|
||||
int secondDigitsString = JSLocale::GetNumberOption(thread, dateTimeOptions,
|
||||
globalConst->GetHandledFractionalSecondDigitsString(),
|
||||
1, 3, 0);
|
||||
skeleton.append(secondDigitsString, 'S');
|
||||
// e. If value is not undefined, then
|
||||
// i. Set hasExplicitFormatComponents to true.
|
||||
if (secondDigitsString > 0) {
|
||||
explicitFormatComponents = 1;
|
||||
}
|
||||
}
|
||||
JSHandle<JSTaggedValue> property(thread, factory->NewFromStdString(item.property).GetTaggedValue());
|
||||
std::string value;
|
||||
|
@ -119,6 +119,8 @@ group("ark_js_moduletest") {
|
||||
"regexpcallthrow",
|
||||
"regexpflagd",
|
||||
"regress",
|
||||
|
||||
#"regressdatetime",
|
||||
"regressdefineproperty",
|
||||
"require",
|
||||
"setobjectwithproto",
|
||||
|
18
test/moduletest/regressdatetime/BUILD.gn
Executable file
18
test/moduletest/regressdatetime/BUILD.gn
Executable file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("regressdatetime") {
|
||||
deps = []
|
||||
}
|
18
test/moduletest/regressdatetime/expect_output.txt
Executable file
18
test/moduletest/regressdatetime/expect_output.txt
Executable file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
undefined
|
||||
undefined
|
37
test/moduletest/regressdatetime/regressdatetime.js
Executable file
37
test/moduletest/regressdatetime/regressdatetime.js
Executable file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
() => (new Intl.DateTimeFormat("en", {fractionalSecondDigits: 0}));
|
||||
|
||||
() => (new Intl.DateTimeFormat("en", {fractionalSecondDigits: 4}));
|
||||
|
||||
print((new Intl.DateTimeFormat("en", {fractionalSecondDigits: 1}))
|
||||
.resolvedOptions().fractionalSecondDigits);
|
||||
|
||||
print((new Intl.DateTimeFormat("en", {fractionalSecondDigits: 2}))
|
||||
.resolvedOptions().fractionalSecondDigits);
|
||||
|
||||
print((new Intl.DateTimeFormat("en", {fractionalSecondDigits: 3}))
|
||||
.resolvedOptions().fractionalSecondDigits);
|
||||
|
||||
print((new Intl.DateTimeFormat()).resolvedOptions().fractionalSecondDigits);
|
||||
|
||||
print((new Intl.DateTimeFormat("en", {fractionalSecondDigits: undefined}))
|
||||
.resolvedOptions().fractionalSecondDigits);
|
||||
|
||||
() => (new Intl.DateTimeFormat(
|
||||
"en", {timeStyle: "short", fractionalSecondDigits: 3}));
|
||||
|
||||
() => (new Intl.DateTimeFormat(
|
||||
"en", {dateStyle: "short", fractionalSecondDigits: 3}));
|
Loading…
Reference in New Issue
Block a user