Skip to content

Commit

Permalink
fix(dateFilter): ignore invalid dates
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource authored and lgalfaso committed Jan 6, 2015
1 parent d2a9a16 commit 1334b8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function dateFilter($locale) {
date = new Date(date);
}

if (!isDate(date)) {
if (!isDate(date) || !isFinite(date.getTime())) {
return date;
}

Expand Down
5 changes: 5 additions & 0 deletions test/ng/filter/filtersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ describe('filters', function() {
expect(date('')).toEqual('');
});

it('should ignore invalid dates', function() {
var invalidDate = new Date('abc');
expect(date(invalidDate)).toBe(invalidDate);
});

it('should do basic filter', function() {
expect(date(noon)).toEqual(date(noon, 'mediumDate'));
expect(date(noon, '')).toEqual(date(noon, 'mediumDate'));
Expand Down

0 comments on commit 1334b8c

Please sign in to comment.