Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Global I18n Standard
提交
dcc33482
G
Global I18n Standard
项目概览
OpenHarmony
/
Global I18n Standard
大约 1 年 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Global I18n Standard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dcc33482
编写于
3月 24, 2022
作者:
S
sunyaozu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改内源问题
Signed-off-by:
N
sunyaozu
<
sunyaozu@huawei.com
>
上级
2f37a218
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
87 addition
and
16 deletion
+87
-16
frameworks/intl/include/date_time_format.h
frameworks/intl/include/date_time_format.h
+4
-0
frameworks/intl/include/i18n_timezone.h
frameworks/intl/include/i18n_timezone.h
+2
-0
frameworks/intl/include/locale_config.h
frameworks/intl/include/locale_config.h
+1
-1
frameworks/intl/include/phone_number_format.h
frameworks/intl/include/phone_number_format.h
+3
-0
frameworks/intl/src/collator.cpp
frameworks/intl/src/collator.cpp
+7
-2
frameworks/intl/src/date_time_format.cpp
frameworks/intl/src/date_time_format.cpp
+23
-2
frameworks/intl/src/i18n_timezone.cpp
frameworks/intl/src/i18n_timezone.cpp
+14
-0
frameworks/intl/src/number_format.cpp
frameworks/intl/src/number_format.cpp
+5
-2
frameworks/intl/src/phone_number_format.cpp
frameworks/intl/src/phone_number_format.cpp
+15
-0
frameworks/intl/src/preferred_language.cpp
frameworks/intl/src/preferred_language.cpp
+6
-0
interfaces/js/kits/src/i18n_addon.cpp
interfaces/js/kits/src/i18n_addon.cpp
+2
-2
interfaces/js/kits/src/intl_addon.cpp
interfaces/js/kits/src/intl_addon.cpp
+5
-7
未找到文件。
frameworks/intl/include/date_time_format.h
浏览文件 @
dcc33482
...
@@ -59,6 +59,9 @@ public:
...
@@ -59,6 +59,9 @@ public:
std
::
string
GetLocaleMatcher
()
const
;
std
::
string
GetLocaleMatcher
()
const
;
std
::
string
GetFormatMatcher
()
const
;
std
::
string
GetFormatMatcher
()
const
;
std
::
string
GetFractionalSecondDigits
()
const
;
std
::
string
GetFractionalSecondDigits
()
const
;
static
std
::
unique_ptr
<
DateTimeFormat
>
CreateInstance
(
const
std
::
vector
<
std
::
string
>
&
localeTags
,
std
::
map
<
std
::
string
,
std
::
string
>
&
configs
);
private:
private:
std
::
string
localeTag
;
std
::
string
localeTag
;
std
::
string
dateStyle
;
std
::
string
dateStyle
;
...
@@ -135,6 +138,7 @@ private:
...
@@ -135,6 +138,7 @@ private:
void
FixPatternPartTwo
();
void
FixPatternPartTwo
();
void
removeAmPmChar
();
void
removeAmPmChar
();
int64_t
GetArrayValue
(
int64_t
*
dateArray
,
size_t
index
,
size_t
size
);
int64_t
GetArrayValue
(
int64_t
*
dateArray
,
size_t
index
,
size_t
size
);
bool
CheckInitSuccess
();
};
};
}
// namespace I18n
}
// namespace I18n
}
// namespace Global
}
// namespace Global
...
...
frameworks/intl/include/i18n_timezone.h
浏览文件 @
dcc33482
...
@@ -32,8 +32,10 @@ public:
...
@@ -32,8 +32,10 @@ public:
std
::
string
GetDisplayName
(
bool
isDST
);
std
::
string
GetDisplayName
(
bool
isDST
);
std
::
string
GetDisplayName
(
std
::
string
localeStr
);
std
::
string
GetDisplayName
(
std
::
string
localeStr
);
std
::
string
GetDisplayName
(
std
::
string
localeStr
,
bool
isDST
);
std
::
string
GetDisplayName
(
std
::
string
localeStr
,
bool
isDST
);
static
std
::
unique_ptr
<
I18nTimeZone
>
CreateInstance
(
std
::
string
zoneID
);
private:
private:
icu
::
TimeZone
*
GetTimeZone
();
icu
::
TimeZone
*
timezone
;
icu
::
TimeZone
*
timezone
;
};
};
}
// namespace I18n
}
// namespace I18n
...
...
frameworks/intl/include/locale_config.h
浏览文件 @
dcc33482
...
@@ -46,6 +46,7 @@ public:
...
@@ -46,6 +46,7 @@ public:
static
std
::
string
GetValidLocale
(
const
std
::
string
&
localeTag
);
static
std
::
string
GetValidLocale
(
const
std
::
string
&
localeTag
);
static
bool
Is24HourClock
();
static
bool
Is24HourClock
();
static
bool
Set24HourClock
(
bool
option
);
static
bool
Set24HourClock
(
bool
option
);
static
bool
CheckPermission
();
private:
private:
static
bool
IsValidLanguage
(
const
std
::
string
&
language
);
static
bool
IsValidLanguage
(
const
std
::
string
&
language
);
...
@@ -96,7 +97,6 @@ private:
...
@@ -96,7 +97,6 @@ private:
static
std
::
set
<
std
::
string
>
validHcTag
;
static
std
::
set
<
std
::
string
>
validHcTag
;
static
bool
listsInitialized
;
static
bool
listsInitialized
;
static
bool
InitializeLists
();
static
bool
InitializeLists
();
static
bool
CheckPermission
();
};
};
}
// namespace I18n
}
// namespace I18n
}
// namespace Global
}
// namespace Global
...
...
frameworks/intl/include/phone_number_format.h
浏览文件 @
dcc33482
...
@@ -31,8 +31,11 @@ public:
...
@@ -31,8 +31,11 @@ public:
virtual
~
PhoneNumberFormat
();
virtual
~
PhoneNumberFormat
();
bool
isValidPhoneNumber
(
const
std
::
string
&
number
)
const
;
bool
isValidPhoneNumber
(
const
std
::
string
&
number
)
const
;
std
::
string
format
(
const
std
::
string
&
number
)
const
;
std
::
string
format
(
const
std
::
string
&
number
)
const
;
static
std
::
unique_ptr
<
PhoneNumberFormat
>
CreateInstance
(
const
std
::
string
&
countryTag
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
);
private:
private:
PhoneNumberUtil
*
GetPhoneNumberUtil
();
PhoneNumberUtil
*
util
;
PhoneNumberUtil
*
util
;
std
::
string
country
;
std
::
string
country
;
PhoneNumberUtil
::
PhoneNumberFormat
phoneNumberFormat
;
PhoneNumberUtil
::
PhoneNumberFormat
phoneNumberFormat
;
...
...
frameworks/intl/src/collator.cpp
浏览文件 @
dcc33482
...
@@ -92,14 +92,19 @@ bool Collator::IsValidCollation(std::string &collation, UErrorCode &status)
...
@@ -92,14 +92,19 @@ bool Collator::IsValidCollation(std::string &collation, UErrorCode &status)
std
::
unique_ptr
<
icu
::
StringEnumeration
>
enumeration
(
std
::
unique_ptr
<
icu
::
StringEnumeration
>
enumeration
(
icu
::
Collator
::
getKeywordValuesForLocale
(
"collation"
,
icu
::
Locale
(
locale
.
getBaseName
()),
false
,
status
));
icu
::
Collator
::
getKeywordValuesForLocale
(
"collation"
,
icu
::
Locale
(
locale
.
getBaseName
()),
false
,
status
));
int
length
;
int
length
;
const
char
*
validCollations
=
enumeration
->
next
(
&
length
,
status
);
const
char
*
validCollations
=
nullptr
;
if
(
enumeration
!=
nullptr
)
{
validCollations
=
enumeration
->
next
(
&
length
,
status
);
}
while
(
validCollations
!=
nullptr
)
{
while
(
validCollations
!=
nullptr
)
{
if
(
!
strcmp
(
validCollations
,
currentCollation
))
{
if
(
!
strcmp
(
validCollations
,
currentCollation
))
{
return
true
;
return
true
;
}
}
if
(
enumeration
!=
nullptr
)
{
validCollations
=
enumeration
->
next
(
&
length
,
status
);
validCollations
=
enumeration
->
next
(
&
length
,
status
);
}
}
}
}
}
return
false
;
return
false
;
}
}
...
...
frameworks/intl/src/date_time_format.cpp
浏览文件 @
dcc33482
...
@@ -77,6 +77,24 @@ DateTimeFormat::~DateTimeFormat()
...
@@ -77,6 +77,24 @@ DateTimeFormat::~DateTimeFormat()
}
}
}
}
bool
DateTimeFormat
::
CheckInitSuccess
()
{
if
(
dateIntvFormat
==
nullptr
||
calendar
==
nullptr
||
dateFormat
==
nullptr
||
localeInfo
==
nullptr
)
{
return
false
;
}
return
true
;
}
std
::
unique_ptr
<
DateTimeFormat
>
DateTimeFormat
::
CreateInstance
(
const
std
::
vector
<
std
::
string
>
&
localeTags
,
std
::
map
<
std
::
string
,
std
::
string
>
&
configs
)
{
std
::
unique_ptr
<
DateTimeFormat
>
dateTimeFormat
=
std
::
make_unique
<
DateTimeFormat
>
(
localeTags
,
configs
);
if
(
!
dateTimeFormat
->
CheckInitSuccess
())
{
return
nullptr
;
}
return
dateTimeFormat
;
}
void
DateTimeFormat
::
InitWithLocale
(
const
std
::
string
&
curLocale
,
std
::
map
<
std
::
string
,
std
::
string
>
&
configs
)
void
DateTimeFormat
::
InitWithLocale
(
const
std
::
string
&
curLocale
,
std
::
map
<
std
::
string
,
std
::
string
>
&
configs
)
{
{
UErrorCode
status
=
U_ZERO_ERROR
;
UErrorCode
status
=
U_ZERO_ERROR
;
...
@@ -228,10 +246,10 @@ void DateTimeFormat::InitDateFormat(UErrorCode &status)
...
@@ -228,10 +246,10 @@ void DateTimeFormat::InitDateFormat(UErrorCode &status)
if
(
!
dateStyle
.
empty
()
||
!
timeStyle
.
empty
())
{
if
(
!
dateStyle
.
empty
()
||
!
timeStyle
.
empty
())
{
DateFormat
::
EStyle
dateStyleValue
=
DateFormat
::
EStyle
::
kNone
;
DateFormat
::
EStyle
dateStyleValue
=
DateFormat
::
EStyle
::
kNone
;
DateFormat
::
EStyle
timeStyleValue
=
DateFormat
::
EStyle
::
kNone
;
DateFormat
::
EStyle
timeStyleValue
=
DateFormat
::
EStyle
::
kNone
;
if
(
!
dateStyle
.
empty
())
{
if
(
!
dateStyle
.
empty
()
&&
dateTimeStyle
.
count
(
dateStyle
)
>
0
)
{
dateStyleValue
=
dateTimeStyle
[
dateStyle
];
dateStyleValue
=
dateTimeStyle
[
dateStyle
];
}
}
if
(
!
timeStyle
.
empty
())
{
if
(
!
timeStyle
.
empty
()
&&
dateTimeStyle
.
count
(
timeStyle
)
>
0
)
{
timeStyleValue
=
dateTimeStyle
[
timeStyle
];
timeStyleValue
=
dateTimeStyle
[
timeStyle
];
}
}
dateFormat
=
DateFormat
::
createDateTimeInstance
(
dateStyleValue
,
timeStyleValue
,
locale
);
dateFormat
=
DateFormat
::
createDateTimeInstance
(
dateStyleValue
,
timeStyleValue
,
locale
);
...
@@ -495,6 +513,9 @@ std::string DateTimeFormat::FormatRange(int64_t *fromDate, size_t fromDateSize,
...
@@ -495,6 +513,9 @@ std::string DateTimeFormat::FormatRange(int64_t *fromDate, size_t fromDateSize,
minute
=
GetArrayValue
(
toDate
,
MINUTE_INDEX
,
toDateSize
);
minute
=
GetArrayValue
(
toDate
,
MINUTE_INDEX
,
toDateSize
);
second
=
GetArrayValue
(
toDate
,
SECOND_INDEX
,
toDateSize
);
second
=
GetArrayValue
(
toDate
,
SECOND_INDEX
,
toDateSize
);
auto
toCalendar
=
std
::
unique_ptr
<
Calendar
>
(
Calendar
::
createInstance
(
locale
,
status
));
auto
toCalendar
=
std
::
unique_ptr
<
Calendar
>
(
Calendar
::
createInstance
(
locale
,
status
));
if
(
toCalendar
==
nullptr
)
{
return
nullptr
;
}
toCalendar
->
clear
();
toCalendar
->
clear
();
toCalendar
->
set
(
year
,
month
,
day
,
hour
,
minute
,
second
);
toCalendar
->
set
(
year
,
month
,
day
,
hour
,
minute
,
second
);
if
(
!
timeZone
.
empty
())
{
if
(
!
timeZone
.
empty
())
{
...
...
frameworks/intl/src/i18n_timezone.cpp
浏览文件 @
dcc33482
...
@@ -39,6 +39,20 @@ I18nTimeZone::~I18nTimeZone()
...
@@ -39,6 +39,20 @@ I18nTimeZone::~I18nTimeZone()
}
}
}
}
icu
::
TimeZone
*
I18nTimeZone
::
GetTimeZone
()
{
return
timezone
;
}
std
::
unique_ptr
<
I18nTimeZone
>
I18nTimeZone
::
CreateInstance
(
std
::
string
zoneID
)
{
std
::
unique_ptr
<
I18nTimeZone
>
i18nTimeZone
=
std
::
make_unique
<
I18nTimeZone
>
(
zoneID
);
if
(
i18nTimeZone
->
GetTimeZone
()
==
nullptr
)
{
return
nullptr
;
}
return
i18nTimeZone
;
}
int32_t
I18nTimeZone
::
GetOffset
(
double
date
)
int32_t
I18nTimeZone
::
GetOffset
(
double
date
)
{
{
int32_t
rawOffset
=
0
;
int32_t
rawOffset
=
0
;
...
...
frameworks/intl/src/number_format.cpp
浏览文件 @
dcc33482
...
@@ -175,8 +175,10 @@ void NumberFormat::ParseConfigs(std::map<std::string, std::string> &configs)
...
@@ -175,8 +175,10 @@ void NumberFormat::ParseConfigs(std::map<std::string, std::string> &configs)
unit
=
configs
[
"unit"
];
unit
=
configs
[
"unit"
];
if
(
configs
.
count
(
"unitDisplay"
)
>
0
)
{
if
(
configs
.
count
(
"unitDisplay"
)
>
0
)
{
unitDisplayString
=
configs
[
"unitDisplay"
];
unitDisplayString
=
configs
[
"unitDisplay"
];
if
(
unitStyle
.
count
(
unitDisplayString
)
>
0
)
{
unitDisplay
=
unitStyle
[
unitDisplayString
];
unitDisplay
=
unitStyle
[
unitDisplayString
];
}
}
}
if
(
configs
.
count
(
"unitUsage"
)
>
0
)
{
if
(
configs
.
count
(
"unitUsage"
)
>
0
)
{
unitUsage
=
configs
[
"unitUsage"
];
unitUsage
=
configs
[
"unitUsage"
];
}
}
...
@@ -185,7 +187,8 @@ void NumberFormat::ParseConfigs(std::map<std::string, std::string> &configs)
...
@@ -185,7 +187,8 @@ void NumberFormat::ParseConfigs(std::map<std::string, std::string> &configs)
currency
=
configs
[
"currency"
];
currency
=
configs
[
"currency"
];
if
(
configs
.
count
(
"currencySign"
)
>
0
)
{
if
(
configs
.
count
(
"currencySign"
)
>
0
)
{
currencySign
=
configs
[
"currencySign"
];
currencySign
=
configs
[
"currencySign"
];
if
(
configs
[
"currencySign"
]
!=
"accounting"
&&
!
signDisplayString
.
empty
())
{
if
(
configs
[
"currencySign"
]
!=
"accounting"
&&
!
signDisplayString
.
empty
()
&&
signAccountingStyle
.
count
(
signDisplayString
)
>
0
)
{
signDisplay
=
signAccountingStyle
[
signDisplayString
];
signDisplay
=
signAccountingStyle
[
signDisplayString
];
}
}
}
}
...
...
frameworks/intl/src/phone_number_format.cpp
浏览文件 @
dcc33482
...
@@ -51,6 +51,21 @@ PhoneNumberFormat::~PhoneNumberFormat()
...
@@ -51,6 +51,21 @@ PhoneNumberFormat::~PhoneNumberFormat()
{
{
}
}
std
::
unique_ptr
<
PhoneNumberFormat
>
PhoneNumberFormat
::
CreateInstance
(
const
std
::
string
&
countryTag
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
)
{
std
::
unique_ptr
<
PhoneNumberFormat
>
phoneNumberFormat
=
std
::
make_unique
<
PhoneNumberFormat
>
(
countryTag
,
options
);
if
(
phoneNumberFormat
->
GetPhoneNumberUtil
()
==
nullptr
)
{
return
nullptr
;
}
return
phoneNumberFormat
;
}
PhoneNumberUtil
*
PhoneNumberFormat
::
GetPhoneNumberUtil
()
{
return
util
;
}
bool
PhoneNumberFormat
::
isValidPhoneNumber
(
const
std
::
string
&
number
)
const
bool
PhoneNumberFormat
::
isValidPhoneNumber
(
const
std
::
string
&
number
)
const
{
{
i18n
::
phonenumbers
::
PhoneNumber
phoneNumber
;
i18n
::
phonenumbers
::
PhoneNumber
phoneNumber
;
...
...
frameworks/intl/src/preferred_language.cpp
浏览文件 @
dcc33482
...
@@ -66,6 +66,9 @@ bool PreferredLanguage::AddPreferredLanguageNonExist(std::vector<std::string> &p
...
@@ -66,6 +66,9 @@ bool PreferredLanguage::AddPreferredLanguageNonExist(std::vector<std::string> &p
bool
PreferredLanguage
::
AddPreferredLanguage
(
const
std
::
string
&
language
,
int
index
)
bool
PreferredLanguage
::
AddPreferredLanguage
(
const
std
::
string
&
language
,
int
index
)
{
{
if
(
!
LocaleConfig
::
CheckPermission
())
{
return
false
;
}
if
(
!
IsValidTag
(
language
))
{
if
(
!
IsValidTag
(
language
))
{
return
false
;
return
false
;
}
}
...
@@ -111,6 +114,9 @@ bool PreferredLanguage::AddPreferredLanguage(const std::string &language, int in
...
@@ -111,6 +114,9 @@ bool PreferredLanguage::AddPreferredLanguage(const std::string &language, int in
bool
PreferredLanguage
::
RemovePreferredLanguage
(
int
index
)
bool
PreferredLanguage
::
RemovePreferredLanguage
(
int
index
)
{
{
if
(
!
LocaleConfig
::
CheckPermission
())
{
return
false
;
}
std
::
vector
<
std
::
string
>
preferredLanguageList
=
GetPreferredLanguageList
();
std
::
vector
<
std
::
string
>
preferredLanguageList
=
GetPreferredLanguageList
();
int
idx
=
index
;
int
idx
=
index
;
if
(
index
<
0
)
{
if
(
index
<
0
)
{
...
...
interfaces/js/kits/src/i18n_addon.cpp
浏览文件 @
dcc33482
...
@@ -958,7 +958,7 @@ bool I18nAddon::InitPhoneNumberFormatContext(napi_env env, napi_callback_info in
...
@@ -958,7 +958,7 @@ bool I18nAddon::InitPhoneNumberFormatContext(napi_env env, napi_callback_info in
return
false
;
return
false
;
}
}
env_
=
env
;
env_
=
env
;
phonenumberfmt_
=
std
::
make_unique
<
PhoneNumberFormat
>
(
country
,
options
);
phonenumberfmt_
=
PhoneNumberFormat
::
CreateInstance
(
country
,
options
);
return
phonenumberfmt_
!=
nullptr
;
return
phonenumberfmt_
!=
nullptr
;
}
}
...
@@ -2456,7 +2456,7 @@ napi_value I18nAddon::I18nTimeZoneConstructor(napi_env env, napi_callback_info i
...
@@ -2456,7 +2456,7 @@ napi_value I18nAddon::I18nTimeZoneConstructor(napi_env env, napi_callback_info i
HiLog
::
Error
(
LABEL
,
"Wrap II18nAddon failed"
);
HiLog
::
Error
(
LABEL
,
"Wrap II18nAddon failed"
);
return
nullptr
;
return
nullptr
;
}
}
obj
->
timezone_
=
std
::
make_unique
<
I18nTimeZone
>
(
zoneID
);
obj
->
timezone_
=
I18nTimeZone
::
CreateInstance
(
zoneID
);
if
(
!
obj
->
timezone_
)
{
if
(
!
obj
->
timezone_
)
{
HiLog
::
Error
(
LABEL
,
"Wrap TimeZone failed"
);
HiLog
::
Error
(
LABEL
,
"Wrap TimeZone failed"
);
return
nullptr
;
return
nullptr
;
...
...
interfaces/js/kits/src/intl_addon.cpp
浏览文件 @
dcc33482
...
@@ -370,7 +370,6 @@ napi_value IntlAddon::DateTimeFormatConstructor(napi_env env, napi_callback_info
...
@@ -370,7 +370,6 @@ napi_value IntlAddon::DateTimeFormatConstructor(napi_env env, napi_callback_info
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_status
status
=
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_status
status
=
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
std
::
vector
<
std
::
string
>
localeTags
;
std
::
vector
<
std
::
string
>
localeTags
;
if
(
argv
[
0
]
!=
nullptr
)
{
if
(
argv
[
0
]
!=
nullptr
)
{
napi_valuetype
valueType
=
napi_valuetype
::
napi_undefined
;
napi_valuetype
valueType
=
napi_valuetype
::
napi_undefined
;
...
@@ -389,31 +388,26 @@ napi_value IntlAddon::DateTimeFormatConstructor(napi_env env, napi_callback_info
...
@@ -389,31 +388,26 @@ napi_value IntlAddon::DateTimeFormatConstructor(napi_env env, napi_callback_info
}
}
}
}
}
}
std
::
map
<
std
::
string
,
std
::
string
>
map
=
{};
std
::
map
<
std
::
string
,
std
::
string
>
map
=
{};
if
(
argv
[
1
]
!=
nullptr
)
{
if
(
argv
[
1
]
!=
nullptr
)
{
GetDateOptionValues
(
env
,
argv
[
1
],
map
);
GetDateOptionValues
(
env
,
argv
[
1
],
map
);
}
}
std
::
unique_ptr
<
IntlAddon
>
obj
=
nullptr
;
std
::
unique_ptr
<
IntlAddon
>
obj
=
nullptr
;
obj
=
std
::
make_unique
<
IntlAddon
>
();
obj
=
std
::
make_unique
<
IntlAddon
>
();
if
(
!
obj
)
{
if
(
!
obj
)
{
HiLog
::
Error
(
LABEL
,
"Create IntlAddon failed"
);
HiLog
::
Error
(
LABEL
,
"Create IntlAddon failed"
);
return
nullptr
;
return
nullptr
;
}
}
status
=
status
=
napi_wrap
(
env
,
thisVar
,
reinterpret_cast
<
void
*>
(
obj
.
get
()),
IntlAddon
::
Destructor
,
nullptr
,
&
obj
->
wrapper_
);
napi_wrap
(
env
,
thisVar
,
reinterpret_cast
<
void
*>
(
obj
.
get
()),
IntlAddon
::
Destructor
,
nullptr
,
&
obj
->
wrapper_
);
if
(
status
!=
napi_ok
)
{
if
(
status
!=
napi_ok
)
{
HiLog
::
Error
(
LABEL
,
"Wrap IntlAddon failed"
);
HiLog
::
Error
(
LABEL
,
"Wrap IntlAddon failed"
);
return
nullptr
;
return
nullptr
;
}
}
if
(
!
obj
->
InitDateTimeFormatContext
(
env
,
info
,
localeTags
,
map
))
{
if
(
!
obj
->
InitDateTimeFormatContext
(
env
,
info
,
localeTags
,
map
))
{
HiLog
::
Error
(
LABEL
,
"Init DateTimeFormat failed"
);
HiLog
::
Error
(
LABEL
,
"Init DateTimeFormat failed"
);
return
nullptr
;
return
nullptr
;
}
}
obj
.
release
();
obj
.
release
();
return
thisVar
;
return
thisVar
;
}
}
...
@@ -428,7 +422,7 @@ bool IntlAddon::InitDateTimeFormatContext(napi_env env, napi_callback_info info,
...
@@ -428,7 +422,7 @@ bool IntlAddon::InitDateTimeFormatContext(napi_env env, napi_callback_info info,
return
false
;
return
false
;
}
}
env_
=
env
;
env_
=
env
;
datefmt_
=
std
::
make_unique
<
DateTimeFormat
>
(
localeTags
,
map
);
datefmt_
=
DateTimeFormat
::
CreateInstance
(
localeTags
,
map
);
return
datefmt_
!=
nullptr
;
return
datefmt_
!=
nullptr
;
}
}
...
@@ -538,6 +532,10 @@ napi_value IntlAddon::FormatDateTimeRange(napi_env env, napi_callback_info info)
...
@@ -538,6 +532,10 @@ napi_value IntlAddon::FormatDateTimeRange(napi_env env, napi_callback_info info)
napi_value
thisVar
=
nullptr
;
napi_value
thisVar
=
nullptr
;
void
*
data
=
nullptr
;
void
*
data
=
nullptr
;
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
napi_get_cb_info
(
env
,
info
,
&
argc
,
argv
,
&
thisVar
,
&
data
);
if
(
argv
[
0
]
==
nullptr
||
argv
[
1
]
==
nullptr
)
{
HiLog
::
Error
(
LABEL
,
"Parameter wrong"
);
return
nullptr
;
}
int64_t
firstYear
=
GetYear
(
env
,
argv
,
0
);
int64_t
firstYear
=
GetYear
(
env
,
argv
,
0
);
int64_t
firstMonth
=
GetMonth
(
env
,
argv
,
0
);
int64_t
firstMonth
=
GetMonth
(
env
,
argv
,
0
);
int64_t
firstDay
=
GetDay
(
env
,
argv
,
0
);
int64_t
firstDay
=
GetDay
(
env
,
argv
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录