Skip to content

Commit

Permalink
fix(datepicker): allow date or datetime strings in fromIso8601 (#7220)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba authored and jelbourn committed Sep 21, 2017
1 parent 3025b30 commit 8436f8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lib/core/datetime/native-date-adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,11 @@ describe('NativeDateAdapter', () => {
expect(adapter.fromIso8601('1985-04-12T23:20:50.52Z')).not.toBeNull();
expect(adapter.fromIso8601('1996-12-19T16:39:57-08:00')).not.toBeNull();
expect(adapter.fromIso8601('1937-01-01T12:00:27.87+00:20')).not.toBeNull();
expect(adapter.fromIso8601('2017-01-01')).not.toBeNull();
expect(adapter.fromIso8601('2017-01-01T00:00:00')).not.toBeNull();
expect(adapter.fromIso8601('1990-13-31T23:59:00Z')).toBeNull();
expect(adapter.fromIso8601('1/1/2017')).toBeNull();
expect(adapter.fromIso8601('2017-01-01T')).toBeNull();
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/datetime/native-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const DEFAULT_DAY_OF_WEEK_NAMES = {
* because the regex will match strings an with out of bounds month, date, etc.
*/
const ISO_8601_REGEX =
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/;
/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))?)?$/;


/** Creates an array and fills it with values. */
Expand Down

0 comments on commit 8436f8c

Please sign in to comment.