@@ -1094,7 +1094,10 @@ describe("date_utils", () => {
10941094 expect ( parseDate ( valueEn , dateFormat , undefined , false ) ) . toEqual (
10951095 expected ,
10961096 ) ;
1097- expect ( parseDate ( valueEn , dateFormat , locale , false ) ) . toBeNull ( ) ;
1097+ // With native Date fallback (restored in v8.x), English month names
1098+ // are parsed even when a different locale is specified, because
1099+ // the native Date constructor is locale-agnostic
1100+ expect ( parseDate ( valueEn , dateFormat , locale , false ) ) . toEqual ( expected ) ;
10981101 } ) ;
10991102
11001103 it ( "should not parse date based on locale without a given locale" , ( ) => {
@@ -1117,6 +1120,63 @@ describe("date_utils", () => {
11171120
11181121 expect ( actual ) . toEqual ( expected ) ;
11191122 } ) ;
1123+
1124+ describe ( "native Date fallback when strictParsing is false (#6164)" , ( ) => {
1125+ it ( "should parse date in different format using native Date fallback" , ( ) => {
1126+ // User types MM/dd/yyyy but dateFormat is yyyy-MM-dd
1127+ const value = "12/05/2025" ;
1128+ const dateFormat = "yyyy-MM-dd" ;
1129+
1130+ const result = parseDate ( value , dateFormat , undefined , false ) ;
1131+ expect ( result ) . not . toBeNull ( ) ;
1132+ expect ( result ?. getFullYear ( ) ) . toBe ( 2025 ) ;
1133+ expect ( result ?. getMonth ( ) ) . toBe ( 11 ) ; // December (0-indexed)
1134+ expect ( result ?. getDate ( ) ) . toBe ( 5 ) ;
1135+ } ) ;
1136+
1137+ it ( "should parse ISO date string using native Date fallback" , ( ) => {
1138+ const value = "2025-12-16" ;
1139+ const dateFormat = "MM/dd/yyyy" ;
1140+
1141+ const result = parseDate ( value , dateFormat , undefined , false ) ;
1142+ expect ( result ) . not . toBeNull ( ) ;
1143+ expect ( result ?. getFullYear ( ) ) . toBe ( 2025 ) ;
1144+ expect ( result ?. getMonth ( ) ) . toBe ( 11 ) ; // December
1145+ expect ( result ?. getDate ( ) ) . toBe ( 16 ) ;
1146+ } ) ;
1147+
1148+ it ( "should parse date with time using native Date fallback" , ( ) => {
1149+ const value = "2025-12-16 3:31:01 PM" ;
1150+ const dateFormat = "yyyy-MM-dd hh:mm aa" ;
1151+
1152+ const result = parseDate ( value , dateFormat , undefined , false ) ;
1153+ expect ( result ) . not . toBeNull ( ) ;
1154+ expect ( result ?. getFullYear ( ) ) . toBe ( 2025 ) ;
1155+ expect ( result ?. getMonth ( ) ) . toBe ( 11 ) ; // December
1156+ expect ( result ?. getDate ( ) ) . toBe ( 16 ) ;
1157+ expect ( result ?. getHours ( ) ) . toBe ( 15 ) ; // 3 PM = 15:00
1158+ expect ( result ?. getMinutes ( ) ) . toBe ( 31 ) ;
1159+ } ) ;
1160+
1161+ it ( "should NOT use native Date fallback when strictParsing is true" , ( ) => {
1162+ const value = "12/05/2025" ;
1163+ const dateFormat = "yyyy-MM-dd" ;
1164+
1165+ const result = parseDate ( value , dateFormat , undefined , true ) ;
1166+ expect ( result ) . toBeNull ( ) ;
1167+ } ) ;
1168+
1169+ it ( "should prefer exact format match over native Date fallback" , ( ) => {
1170+ const value = "2025-12-05" ;
1171+ const dateFormat = "yyyy-MM-dd" ;
1172+
1173+ const result = parseDate ( value , dateFormat , undefined , false ) ;
1174+ expect ( result ) . not . toBeNull ( ) ;
1175+ expect ( result ?. getFullYear ( ) ) . toBe ( 2025 ) ;
1176+ expect ( result ?. getMonth ( ) ) . toBe ( 11 ) ; // December
1177+ expect ( result ?. getDate ( ) ) . toBe ( 5 ) ;
1178+ } ) ;
1179+ } ) ;
11201180 } ) ;
11211181
11221182 describe ( "isMonthInRange" , ( ) => {
0 commit comments