@@ -487,6 +487,11 @@ public Map<String, String> apply(String value) {
487487 protected static final OptionKey <Boolean > TOP_LEVEL_AWAIT = new OptionKey <>(false );
488488 @ CompilationFinal private boolean topLevelAwait ;
489489
490+ public static final String USE_UTC_FOR_LEGACY_DATES_NAME = JS_OPTION_PREFIX + "use-utc-for-legacy-dates" ;
491+ @ Option (name = USE_UTC_FOR_LEGACY_DATES_NAME , category = OptionCategory .EXPERT , stability = OptionStability .STABLE , help = "Determines what time zone (UTC or local time zone) should be used when UTC offset is absent in a parsed date." ) //
492+ public static final OptionKey <Boolean > USE_UTC_FOR_LEGACY_DATES = new OptionKey <>(true );
493+ @ CompilationFinal private boolean useUTCForLegacyDates ;
494+
490495 JSContextOptions (JSParserOptions parserOptions , OptionValues optionValues ) {
491496 this .parserOptions = parserOptions ;
492497 this .optionValues = optionValues ;
@@ -571,6 +576,7 @@ private void cacheOptions() {
571576 this .maxPrototypeChainLength = readIntegerOption (MAX_PROTOTYPE_CHAIN_LENGTH );
572577 this .asyncStackTraces = readBooleanOption (ASYNC_STACK_TRACES );
573578 this .topLevelAwait = TOP_LEVEL_AWAIT .hasBeenSet (optionValues ) ? readBooleanOption (TOP_LEVEL_AWAIT ) : getEcmaScriptVersion () >= JSConfig .ECMAScript2022 ;
579+ this .useUTCForLegacyDates = USE_UTC_FOR_LEGACY_DATES .hasBeenSet (optionValues ) ? readBooleanOption (USE_UTC_FOR_LEGACY_DATES ) : !v8CompatibilityMode ;
574580
575581 this .propertyCacheLimit = readIntegerOption (PROPERTY_CACHE_LIMIT );
576582 this .functionCacheLimit = readIntegerOption (FUNCTION_CACHE_LIMIT );
@@ -925,6 +931,10 @@ public boolean isAsyncStackTraces() {
925931 return asyncStackTraces ;
926932 }
927933
934+ public boolean shouldUseUTCForLegacyDates () {
935+ return useUTCForLegacyDates ;
936+ }
937+
928938 @ Override
929939 public int hashCode () {
930940 int hash = 5 ;
@@ -973,6 +983,7 @@ public int hashCode() {
973983 hash = 53 * hash + this .propertyCacheLimit ;
974984 hash = 53 * hash + this .functionCacheLimit ;
975985 hash = 53 * hash + (this .topLevelAwait ? 1 : 0 );
986+ hash = 53 * hash + (this .useUTCForLegacyDates ? 1 : 0 );
976987 return hash ;
977988 }
978989
@@ -1120,6 +1131,9 @@ public boolean equals(Object obj) {
11201131 if (this .topLevelAwait != other .topLevelAwait ) {
11211132 return false ;
11221133 }
1134+ if (this .useUTCForLegacyDates != other .useUTCForLegacyDates ) {
1135+ return false ;
1136+ }
11231137 return Objects .equals (this .parserOptions , other .parserOptions );
11241138 }
11251139}
0 commit comments