• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/*
17 * @tc.name:datecase
18 * @tc.desc:test date
19 * @tc.type: FUNC
20 * @tc.require: issueI5NO8G
21 */
22var d1 = new Date("2023-02-19T11:13:48.132Z");
23var d2 = new Date("Thu Nov 19 2020 20:18:18 GMT");
24var d3 = new Date("Thu, 21 Nov 2023 13:23:26 GMT");
25var d4 = new Date("2021-12-25 03:25:45.476Z");
26var d5 = new Date("January 13,2016 22:19:35 GMT");
27
28print(d1.getTime() == 1676805228132);
29print(d1.getFullYear() == 2023);
30print(d1.getMonth() == 1);
31print(d1.getDate() == 19);
32
33print(d2.getTime() == 1605817098000);
34print(d2.getFullYear() == 2020);
35print(d3.getMonth() == 10);
36
37print(d3.getTime() == 1700573006000);
38print(d3.getFullYear() == 2023);
39print(d3.getMonth() == 10);
40print(d3.getDate() == 21);
41
42print(d4.getTime() == 1640402745476);
43print(d4.getFullYear() == 2021);
44print(d4.getMonth() == 11);
45print(d4.getDate() == 25);
46
47print(d5.getTime() == 1452723575000);
48print(d5.getFullYear() == 2016);
49print(d5.getMonth() == 0);
50