Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 025c921

Browse files
Henning Teekbtford
Henning Teek
authored andcommitted
fix(dateFilter): allow negative millisecond value strings
1 parent ac2d06b commit 025c921

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ng/filter/filters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ var DATE_FORMATS = {
260260
};
261261

262262
var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,
263-
NUMBER_STRING = /^\d+$/;
263+
NUMBER_STRING = /^\-?\d+$/;
264264

265265
/**
266266
* @ngdoc filter

test/ng/filter/filtersSpec.js

+4
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ describe('filters', function() {
246246
toEqual('September 03, 1');
247247
});
248248

249+
it('should accept negative numbers as strings', function() {
250+
expect(date('-1')).toEqual('Dec 31, 1969');
251+
});
252+
249253
it('should format timezones correctly (as per ISO_8601)', function() {
250254
//Note: TzDate's first argument is offset, _not_ timezone.
251255
var utc = new angular.mock.TzDate( 0, '2010-09-03T12:05:08.000Z');

0 commit comments

Comments
 (0)