mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-24 02:30:03 +00:00
BugFix:Fix UT errors in DateTimeFormat_004
Setting timezone in DateTimeFormat_004 issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8DP9I Signed-off-by: hecunmao <hecunmao@huawei.com> Change-Id: I05a9f0f5d694b8eea4c2cc995815abdc904972b5
This commit is contained in:
parent
3fa37c9f1e
commit
384230a49c
@ -662,13 +662,16 @@ HWTEST_F_L0(BuiltinsDateTimeFormatTest, DateTimeFormat_004)
|
||||
JSHandle<JSTaggedValue> dateStyleValue(factory->NewFromASCII("dateStyle"));
|
||||
JSHandle<JSTaggedValue> timeStyleeValue(factory->NewFromASCII("timeStyle"));
|
||||
JSHandle<JSTaggedValue> hour12Value(factory->NewFromASCII("hour12"));
|
||||
JSHandle<JSTaggedValue> timeZone(factory->NewFromASCII("timeZone"));
|
||||
JSHandle<JSTaggedValue> timeZoneValue(factory->NewFromASCII("UTC"));
|
||||
JSObject::SetProperty(thread, optionsObj, dateStyleValue, fullValue);
|
||||
JSObject::SetProperty(thread, optionsObj, timeStyleeValue, fullValue);
|
||||
JSObject::SetProperty(thread, optionsObj, hour12Value, falseValue);
|
||||
JSObject::SetProperty(thread, optionsObj, timeZone, timeZoneValue);
|
||||
auto constructorResult = JSDateTimeFormatConstructor(thread, optionsObj, localesString);
|
||||
JSHandle<EcmaString> resultStr =
|
||||
JSDateTimeFormat::FormatDateTime(thread, JSHandle<JSDateTimeFormat>(thread, constructorResult), 0.0);
|
||||
EXPECT_STREQ("1970年1月1日星期四 中国标准时间 08:00:00", EcmaStringAccessor(resultStr).ToCString().c_str());
|
||||
EXPECT_STREQ("1970年1月1日星期四 协调世界时 00:00:00", EcmaStringAccessor(resultStr).ToCString().c_str());
|
||||
}
|
||||
} // namespace panda::test
|
||||
|
||||
|
@ -293,9 +293,9 @@ icu::UnicodeString ReplaceSkeleton(const icu::UnicodeString input, HourCycleOpti
|
||||
}
|
||||
|
||||
std::unique_ptr<icu::SimpleDateFormat> DateTimeStylePattern(DateTimeStyleOption dateStyle,
|
||||
DateTimeStyleOption timeStyle,
|
||||
icu::Locale &icuLocale,
|
||||
HourCycleOption hc,
|
||||
DateTimeStyleOption timeStyle,
|
||||
icu::Locale &icuLocale,
|
||||
HourCycleOption hc,
|
||||
icu::DateTimePatternGenerator *generator)
|
||||
{
|
||||
std::unique_ptr<icu::SimpleDateFormat> result;
|
||||
@ -304,7 +304,7 @@ std::unique_ptr<icu::SimpleDateFormat> DateTimeStylePattern(DateTimeStyleOption
|
||||
result.reset(reinterpret_cast<icu::SimpleDateFormat *>(
|
||||
icu::DateFormat::createDateTimeInstance(icuDateStyle, icuTimeStyle, icuLocale)));
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::UnicodeString pattern;
|
||||
icu::UnicodeString pattern("");
|
||||
pattern = result->toPattern(pattern);
|
||||
icu::UnicodeString skeleton = icu::DateTimePatternGenerator::staticGetSkeleton(pattern, status);
|
||||
ASSERT_PRINT(U_SUCCESS(status), "staticGetSkeleton failed");
|
||||
@ -583,7 +583,7 @@ JSHandle<JSDateTimeFormat> JSDateTimeFormat::InitializeDateTimeFormat(JSThread *
|
||||
if (explicitFormatComponents != 0) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Invalid option : option", dateTimeFormat);
|
||||
}
|
||||
simpleDateFormatIcu = DateTimeStylePattern(dateStyle, timeStyle, icuLocale,
|
||||
simpleDateFormatIcu = DateTimeStylePattern(dateStyle, timeStyle, icuLocale,
|
||||
hc, generator.get());
|
||||
}
|
||||
if (U_FAILURE(status) != 0) {
|
||||
|
@ -46,9 +46,9 @@ icu::DateFormat::EStyle DateTimeStyleToEStyle(DateTimeStyleOption style);
|
||||
HourCycleOption HourCycleFromPattern(const icu::UnicodeString pattern);
|
||||
icu::UnicodeString ReplaceSkeleton(const icu::UnicodeString input, HourCycleOption hc);
|
||||
std::unique_ptr<icu::SimpleDateFormat> DateTimeStylePattern(DateTimeStyleOption dateStyle,
|
||||
DateTimeStyleOption timeStyle,
|
||||
icu::Locale &icuLocale,
|
||||
HourCycleOption hc,
|
||||
DateTimeStyleOption timeStyle,
|
||||
icu::Locale &icuLocale,
|
||||
HourCycleOption hc,
|
||||
icu::DateTimePatternGenerator *generator);
|
||||
|
||||
using IcuPatternDescVect = std::vector<IcuPatternDesc>;
|
||||
|
Loading…
Reference in New Issue
Block a user