Skip to content

Commit 8436f8c

Browse files
mmalerbajelbourn
authored andcommitted
fix(datepicker): allow date or datetime strings in fromIso8601 (#7220)
1 parent 3025b30 commit 8436f8c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/lib/core/datetime/native-date-adapter.spec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,11 @@ describe('NativeDateAdapter', () => {
336336
expect(adapter.fromIso8601('1985-04-12T23:20:50.52Z')).not.toBeNull();
337337
expect(adapter.fromIso8601('1996-12-19T16:39:57-08:00')).not.toBeNull();
338338
expect(adapter.fromIso8601('1937-01-01T12:00:27.87+00:20')).not.toBeNull();
339+
expect(adapter.fromIso8601('2017-01-01')).not.toBeNull();
340+
expect(adapter.fromIso8601('2017-01-01T00:00:00')).not.toBeNull();
339341
expect(adapter.fromIso8601('1990-13-31T23:59:00Z')).toBeNull();
340342
expect(adapter.fromIso8601('1/1/2017')).toBeNull();
343+
expect(adapter.fromIso8601('2017-01-01T')).toBeNull();
341344
});
342345
});
343346

src/lib/core/datetime/native-date-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const DEFAULT_DAY_OF_WEEK_NAMES = {
4444
* because the regex will match strings an with out of bounds month, date, etc.
4545
*/
4646
const ISO_8601_REGEX =
47-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/;
47+
/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;
4848

4949

5050
/** Creates an array and fills it with values. */

0 commit comments

Comments
 (0)