mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-19 08:00:23 +00:00
fix date filter to igrone falsy input
This commit is contained in:
parent
a0ac6725ed
commit
c5cfe2b393
2 changed files with 7 additions and 1 deletions
|
|
@ -75,7 +75,7 @@ var DATE_FORMATS = {
|
|||
var DATE_FORMATS_SPLIT = /([^yMdHhmsaZ]*)(y+|M+|d+|H+|h+|m+|s+|a|Z)(.*)/;
|
||||
|
||||
angularFilter.date = function(date, format) {
|
||||
if (!date instanceof Date) return date;
|
||||
if (!(date instanceof Date)) return date;
|
||||
var text = date.toLocaleDateString(), fn;
|
||||
if (format && isString(format)) {
|
||||
text = '';
|
||||
|
|
|
|||
|
|
@ -100,6 +100,12 @@ describe('filter', function(){
|
|||
midnight.getTimezoneOffset =
|
||||
function() { return 7 * 60; };
|
||||
|
||||
it('should ignore falsy inputs', function() {
|
||||
expect(filter.date(null)).toEqual(null);
|
||||
expect(filter.date('')).toEqual('');
|
||||
expect(filter.date(123)).toEqual(123);
|
||||
});
|
||||
|
||||
it('should do basic filter', function() {
|
||||
expect(filter.date(noon)).toEqual(noon.toLocaleDateString());
|
||||
expect(filter.date(noon, '')).toEqual(noon.toLocaleDateString());
|
||||
|
|
|
|||
Loading…
Reference in a new issue