Skip to content

Commit cd4e442

Browse files
iamstoliskassifar
authored andcommitted
Testing the interpretation of parsed dates in various modes.
(cherry picked from commit 3885c13)
1 parent e3cc92b commit cd4e442

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/*
9+
* Test of the interpretation of parsed dates (in the default mode).
10+
*
11+
* @option timezone=IST
12+
*/
13+
14+
load('assert.js');
15+
load('date_parse_common.js');
16+
17+
assertSame(dateOnlyUTC, zDateOnlyEcma.toString());
18+
assertSame(dateOnlyUTC, zDateOnlyLegacy.toString());
19+
20+
assertSame(dateTimeUTC, zDateTimeEcma.toString());
21+
assertSame(dateTimeUTC, zDateTimeLegacy.toString());
22+
23+
assertSame(dateOnlyUTC, dateOnlyEcma.toString());
24+
assertSame(dateOnlyUTC, dateOnlyLegacy.toString());
25+
26+
assertSame(dateTimeLocal, dateTimeEcma.toString());
27+
assertSame(dateTimeLocal, dateTimeLegacy.toString());
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/*
9+
* Common definitions for tests of the interpretation of parsed dates.
10+
*
11+
* @option timezone IST
12+
*/
13+
14+
var zDateOnlyEcma = new Date("2023-09-28Z");
15+
var zDateOnlyLegacy = new Date("2023 09 28Z");
16+
17+
var zDateTimeEcma = new Date("2023-09-28T00:31:25Z");
18+
var zDateTimeLegacy = new Date("2023 09 28 00:31:25Z");
19+
20+
var dateOnlyEcma = new Date("2023-09-28");
21+
var dateOnlyLegacy = new Date("2023 09 28");
22+
23+
var dateTimeEcma = new Date("2023-09-28T00:31:25");
24+
var dateTimeLegacy = new Date("2023 09 28 00:31:25");
25+
26+
// Possible results
27+
var dateOnlyUTC = "Thu Sep 28 2023 05:30:00 GMT+0530 (IST)";
28+
var dateTimeUTC = "Thu Sep 28 2023 06:01:25 GMT+0530 (IST)";
29+
var dateOnlyLocal = "Thu Sep 28 2023 00:00:00 GMT+0530 (IST)";
30+
var dateTimeLocal = "Thu Sep 28 2023 00:31:25 GMT+0530 (IST)";
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/*
9+
* Test of the interpretation of parsed dates (with use-utc-for-legacy-dates=false).
10+
*
11+
* @option timezone=IST
12+
* @option use-utc-for-legacy-dates=false
13+
*/
14+
15+
load('assert.js');
16+
load('date_parse_common.js');
17+
18+
assertSame(dateOnlyUTC, zDateOnlyEcma.toString());
19+
assertSame(dateOnlyUTC, zDateOnlyLegacy.toString());
20+
21+
assertSame(dateTimeUTC, zDateTimeEcma.toString());
22+
assertSame(dateTimeUTC, zDateTimeLegacy.toString());
23+
24+
assertSame(dateOnlyUTC, dateOnlyEcma.toString());
25+
assertSame(dateOnlyLocal, dateOnlyLegacy.toString());
26+
27+
assertSame(dateTimeLocal, dateTimeEcma.toString());
28+
assertSame(dateTimeLocal, dateTimeLegacy.toString());
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/*
9+
* Test of the interpretation of parsed dates (in nashorn-compat mode).
10+
*
11+
* @option timezone=IST
12+
* @option nashorn-compat
13+
*/
14+
15+
load('assert.js');
16+
load('date_parse_common.js');
17+
18+
assertSame(dateOnlyUTC, zDateOnlyEcma.toString());
19+
assertSame(dateOnlyUTC, zDateOnlyLegacy.toString());
20+
21+
assertSame(dateTimeUTC, zDateTimeEcma.toString());
22+
assertSame(dateTimeUTC, zDateTimeLegacy.toString());
23+
24+
assertSame(dateOnlyUTC, dateOnlyEcma.toString());
25+
assertSame(dateOnlyLocal, dateOnlyLegacy.toString());
26+
27+
assertSame(dateTimeUTC, dateTimeEcma.toString());
28+
assertSame(dateTimeLocal, dateTimeLegacy.toString());
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2025, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/*
9+
* Test of the interpretation of parsed dates (with use-utc-for-legacy-dates=true).
10+
*
11+
* @option timezone=IST
12+
* @option use-utc-for-legacy-dates=true
13+
*/
14+
15+
load('assert.js');
16+
load('date_parse_common.js');
17+
18+
// use-utc-for-legacy-dates=true is the default mode
19+
// so, it should be the same as date_parse.js
20+
21+
load('date_parse.js');

0 commit comments

Comments
 (0)