File tree Expand file tree Collapse file tree 9 files changed +145
-6
lines changed
com.oracle.truffle.js.parser/src/com/oracle/truffle/js/parser/date
com.oracle.truffle.js.test
src/com/oracle/truffle/js/test Expand file tree Collapse file tree 9 files changed +145
-6
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2018, 2023 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2018, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
@@ -746,7 +746,8 @@ private boolean patchResult(final boolean strict) {
746746 }
747747
748748 private boolean isUTCDefaultTimezone (boolean dateOnly , boolean strict ) {
749- return (strict || realm .getContext ().getLanguageOptions ().useUTCForLegacyDates ()) && dateOnly ;
749+ return realm .getContext ().isOptionNashornCompatibilityMode () ? strict :
750+ (dateOnly && (strict || realm .getContext ().getLanguageOptions ().useUTCForLegacyDates ()));
750751 }
751752
752753 private static void addName (final String str , final int type , final int value ) {
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2024, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2024, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
66 */
77
88/**
99 * Regression test of the handling of SafeInteger by PluralRules.
10+ *
11+ * @option locale=en
1012 */
1113
1214load ( 'assert.js' ) ;
Original file line number Diff line number Diff line change 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 ( ) ) ;
Original file line number Diff line number Diff line change 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)" ;
Original file line number Diff line number Diff line change 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 ( ) ) ;
Original file line number Diff line number Diff line change 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 ( ) ) ;
Original file line number Diff line number Diff line change 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' ) ;
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2020, 2024 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2020, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
4848import org .graalvm .polyglot .Context ;
4949import org .junit .Test ;
5050
51+ import com .oracle .truffle .js .runtime .JSContextOptions ;
5152import com .oracle .truffle .js .test .JSTest ;
5253import com .oracle .truffle .js .test .polyglot .ForeignBoxedObject ;
5354import com .oracle .truffle .js .test .polyglot .ForeignNull ;
@@ -84,7 +85,7 @@ public void testForeignBoxedString() {
8485
8586 @ Test
8687 public void testForeignBoxedNumber () {
87- try (Context context = JSTest .newContextBuilder ().build ()) {
88+ try (Context context = JSTest .newContextBuilder ().option ( JSContextOptions . LOCALE_NAME , "en" ). build ()) {
8889 context .getBindings ("js" ).putMember ("obj" , ForeignBoxedObject .createNew (42 ));
8990 assertTrue (context .eval (ID , "typeof Object(obj) === 'object'" ).asBoolean ());
9091 assertTrue (context .eval (ID , "typeof obj.valueOf === 'function'" ).asBoolean ());
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2022, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2022, 2025 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
@@ -86,6 +86,7 @@ public void testIntl() {
8686
8787 private static Context newContext (boolean intl ) {
8888 return JSTest .newContextBuilder ().//
89+ option (JSContextOptions .LOCALE_NAME , "en" ).//
8990 option (JSContextOptions .TIME_ZONE_NAME , "Europe/Prague" ).//
9091 option (JSContextOptions .INTL_402_NAME , Boolean .toString (intl )).//
9192 option (JSContextOptions .ZONE_RULES_BASED_TIME_ZONES_NAME , "true" ).//
You can’t perform that action at this time.
0 commit comments