File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
src/material/core/datetime Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
176
176
return new Date ( value ) ;
177
177
}
178
178
179
- const dateParts = ( value as string )
179
+ const dateParts = value
180
180
. trim ( )
181
181
. split ( DATE_COMPONENT_SEPARATOR_REGEX )
182
182
. map ( part => parseInt ( part , 10 ) )
@@ -221,13 +221,14 @@ export class NativeDateAdapter extends DateAdapter<Date> {
221
221
}
222
222
}
223
223
224
- if (
225
- year !== null &&
226
- month !== null &&
227
- day !== null &&
228
- this . _dateComponentsAreValid ( year , month , day )
229
- ) {
230
- return this . createDate ( year , month , day ) ;
224
+ if ( year !== null && month !== null && day !== null ) {
225
+ const date = this . createDate ( year , month , day ) ;
226
+
227
+ if ( date . getFullYear ( ) === year && date . getMonth ( ) === month && date . getDate ( ) === day ) {
228
+ return date ;
229
+ }
230
+
231
+ return this . invalid ( ) ;
231
232
}
232
233
233
234
return this . _nativeParseFallback ( value ) ;
You can’t perform that action at this time.
0 commit comments