Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c973d630
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c973d630
编写于
11月 18, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6570 fix problems with commonlibrary intl timezone
Merge pull request !6570 from zhujie/master
上级
3da6a741
8862b12a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
132 addition
and
14 deletion
+132
-14
commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.properties.test.js
...ntl_lib_standard/src/main/js/test/Intl.properties.test.js
+120
-11
commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.test.js
...ets_utils/intl_lib_standard/src/main/js/test/Intl.test.js
+12
-3
未找到文件。
commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.properties.test.js
浏览文件 @
c973d630
...
...
@@ -221,10 +221,10 @@ describe('etsIntlPtsFunTest', function () {
* @tc.type : Function
* @tc.level : Level 0
*/
it
(
'
S
tringTest
015
'
,
0
,
function
()
{
it
(
'
S
UB_ARK_ETS_INTL_STRING_PROTOTYPE_
015
'
,
0
,
function
()
{
stringTest
=
"
a
"
;
var
value
=
stringTest
.
localeCompare
(
'
zz
'
,
'
sv
'
,
{
sensitivity
:
'
accent
'
});
console
.
log
(
'
S
tringTest
015 :
'
+
value
);
console
.
log
(
'
S
UB_ARK_ETS_INTL_STRING_PROTOTYPE_
015 :
'
+
value
);
expect
(
value
).
assertEqual
(
-
1
);
})
/**
...
...
@@ -1018,8 +1018,20 @@ describe('etsIntlPtsFunTest', function () {
it
(
'
SUB_ARK_ETS_INTL_DATE_PROTOTYPE_001
'
,
0
,
function
()
{
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleString
();
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
10/20/2022, 6:00:00 PM
"
;
console
.
log
(
'
DateTest001 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
10/20/2022, 6:00:00 PM
'
);
console
.
log
(
'
[TIMEZONE]DateTest001 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleString
();
console
.
log
(
'
[UTIME]DateTest001 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest001 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1033,8 +1045,20 @@ describe('etsIntlPtsFunTest', function () {
it
(
'
SUB_ARK_ETS_INTL_DATE_PROTOTYPE_002
'
,
0
,
function
()
{
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleString
(
'
en-GB
'
);
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
20/10/2022, 18:00:00
"
;
console
.
log
(
'
DateTest002 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
20/10/2022, 18:00:00
'
);
console
.
log
(
'
[TIMEZONE]DateTest002 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleString
(
'
en-GB
'
);
console
.
log
(
'
[UTIME]DateTest002 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest002 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1048,8 +1072,20 @@ describe('etsIntlPtsFunTest', function () {
it
(
'
SUB_ARK_ETS_INTL_DATE_PROTOTYPE_003
'
,
0
,
function
()
{
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleString
(
'
ko-KR
'
);
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
2022. 10. 20. 오후 6:00:00
"
;
console
.
log
(
'
DateTest003 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
2022. 10. 20. 오후 6:00:00
'
);
console
.
log
(
'
[TIMEZONE]DateTest003 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleString
(
'
ko-KR
'
);
console
.
log
(
'
[UTIME]DateTest003 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest003 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1093,8 +1129,20 @@ describe('etsIntlPtsFunTest', function () {
it
(
'
SUB_ARK_ETS_INTL_DATE_PROTOTYPE_006
'
,
0
,
function
()
{
var
date
=
new
Date
(
2022
,
9
,
20
,
18
,
0
,
0
);
var
value
=
date
.
toLocaleString
(
'
zh
'
,
{
timeZone
:
'
UTC
'
});
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
2022/10/20 下午6:00:00
"
;
console
.
log
(
'
DateTest006 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
2022/10/20 下午6:00:00
'
);
console
.
log
(
'
[TIMEZONE]DateTest006 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
+
timediff
);
var
utimeString
=
utime
.
toLocaleString
(
'
zh
'
,
{
timeZone
:
'
UTC
'
});
console
.
log
(
'
[UTIME]DateTest006 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest006 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1249,8 +1297,20 @@ describe('etsIntlPtsFunTest', function () {
var
options
=
{
weekday
:
'
long
'
,
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
};
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleDateString
(
'
de-DE
'
,
{
hour12
:
false
,
options
:
options
});
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
20.10.2022
"
;
console
.
log
(
'
DateTest016 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
20.10.2022
'
);
console
.
log
(
'
[TIMEZONE]DateTest016 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleDateString
(
'
de-DE
'
,
{
hour12
:
false
,
options
:
options
});
console
.
log
(
'
[UTIME]DateTest016 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest016 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1265,7 +1325,20 @@ describe('etsIntlPtsFunTest', function () {
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleTimeString
();
console
.
log
(
'
DateTest017 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
6:00:00 PM
'
);
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
6:00:00 PM
"
;
console
.
log
(
'
DateTest017 :
'
+
value
);
console
.
log
(
'
[TIMEZONE]DateTest017 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleTimeString
();
console
.
log
(
'
[UTIME]DateTest017 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest017 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1318,8 +1391,20 @@ describe('etsIntlPtsFunTest', function () {
var
options
=
{
timeZone
:
'
UTC
'
,
timeZoneName
:
'
short
'
};
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleTimeString
(
'
it-IT
'
,
{
options
:
options
});
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
18:00:00
"
;
console
.
log
(
'
DateTest020 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
18:00:00
'
);
console
.
log
(
'
[TIMEZONE]DateTest020 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleTimeString
(
'
it-IT
'
,
{
options
:
options
});
console
.
log
(
'
[UTIME]DateTest020 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest020 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1334,8 +1419,20 @@ describe('etsIntlPtsFunTest', function () {
var
options
=
{
timeZone
:
'
UTC
'
,
timeZoneName
:
'
short
'
};
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleTimeString
(
'
it-IT
'
,
{
hour12
:
false
,
options
:
options
});
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
18:00:00
"
;
console
.
log
(
'
DateTest021 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
18:00:00
'
);
console
.
log
(
'
[TIMEZONE]DateTest021 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleTimeString
(
'
it-IT
'
,
{
hour12
:
false
,
options
:
options
});
console
.
log
(
'
[UTIME]DateTest021 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest021 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
/**
...
...
@@ -1350,8 +1447,20 @@ describe('etsIntlPtsFunTest', function () {
var
options
=
{
weekday
:
'
long
'
,
year
:
'
numeric
'
,
month
:
'
long
'
,
day
:
'
numeric
'
};
var
date
=
new
Date
(
Date
.
UTC
(
2022
,
9
,
20
,
18
,
0
,
0
));
var
value
=
date
.
toLocaleTimeString
(
'
de-DE
'
,
{
hour12
:
true
,
options
:
options
});
var
timezone
=
new
Date
().
getTimezoneOffset
();
var
zerotime
=
"
6:00:00 PM
"
;
console
.
log
(
'
DateTest022 :
'
+
value
);
expect
(
value
).
assertEqual
(
'
6:00:00 PM
'
);
console
.
log
(
'
[TIMEZONE]DateTest022 :
'
+
timezone
);
if
(
timezone
==
0
)
{
expect
(
value
).
assertEqual
(
zerotime
);
}
else
{
var
timediff
=
0
-
(
parseInt
(
timezone
)
*
60
*
1000
);
var
utime
=
new
Date
(
date
.
getTime
()
-
timediff
);
var
utimeString
=
utime
.
toLocaleTimeString
(
'
de-DE
'
,
{
hour12
:
true
,
options
:
options
});
console
.
log
(
'
[UTIME]DateTest003 timediff:
'
+
timediff
);
console
.
log
(
'
[UTIME]DateTest003 :
'
+
utimeString
);
expect
(
utimeString
).
assertEqual
(
zerotime
);
}
})
console
.
log
(
'
*************array prototype object*************
'
);
...
...
commonlibrary/ets_utils/intl_lib_standard/src/main/js/test/Intl.test.js
浏览文件 @
c973d630
...
...
@@ -54,13 +54,18 @@ describe('etsIntlFunTest', function () {
* @tc.level : Level 0
*/
it
(
'
SUB_ARK_ETS_INTL_DATETIMEFORMAT_003
'
,
0
,
function
()
{
var
newDate
=
new
Date
((
24
*
60
*
60
*
1000
)
*
(
52
*
365
+
9
*
30
+
23
));
var
options
=
{
year
:
"
2-digit
"
,
month
:
"
2-digit
"
,
day
:
"
2-digit
"
,
hour
:
"
2-digit
"
,
minute
:
"
2-digit
"
,
timeZoneName
:
"
short
"
};
var
intlObj
=
new
Intl
.
DateTimeFormat
(
"
en-US
"
,
options
).
format
;
console
.
log
(
"
intlDateTimeFormatTest003::
"
+
intlObj
(
newDate
));
expect
(
intlObj
(
newDate
)).
assertEqual
(
"
10/08/22, 12:00 AM GMT
"
);
if
(
intlObj
(
newDate
).
indexOf
(
'
CST
'
)
!=
-
1
)
{
expect
(
intlObj
(
newDate
)).
assertEqual
(
"
10/08/22, 08:00 AM CST
"
);
}
else
{
expect
(
intlObj
(
newDate
)).
assertEqual
(
"
10/08/22, 12:00 AM GMT
"
);
}
})
/**
...
...
@@ -78,7 +83,11 @@ describe('etsIntlFunTest', function () {
timeZoneName
:
"
short
"
};
var
intlObj
=
new
Intl
.
DateTimeFormat
(
"
en
"
,
options
).
format
;
console
.
log
(
"
intlDateTimeFormatTest004::
"
+
intlObj
(
newDate
));
expect
(
intlObj
(
newDate
)).
assertEqual
(
"
10/08/22, 12:00 AM GMT
"
);
if
(
intlObj
(
newDate
).
indexOf
(
'
CST
'
)
!=
-
1
)
{
expect
(
intlObj
(
newDate
)).
assertEqual
(
"
10/08/22, 08:00 AM CST
"
);
}
else
{
expect
(
intlObj
(
newDate
)).
assertEqual
(
"
10/08/22, 12:00 AM GMT
"
);
}
})
/**
...
...
@@ -277,7 +286,7 @@ describe('etsIntlFunTest', function () {
expect
(
intlObj
.
resolvedOptions
().
timeZoneName
).
assertEqual
(
'
short
'
);
var
parts
=
intlObj
.
formatToParts
(
newDate
);
var
partValues
=
parts
.
map
(
p
=>
p
.
value
);
expect
(
partValues
.
length
).
assertEqual
(
1
1
);
expect
(
partValues
.
length
).
assertEqual
(
1
2
);
expect
(
partValues
[
0
]).
assertEqual
(
'
2022
'
);
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录