mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix(dateFilter): support sub-second precision on dateFilter
This commit is contained in:
parent
05c88b866b
commit
f299fd5122
2 changed files with 14 additions and 1 deletions
|
|
@ -320,7 +320,7 @@ dateFilter.$inject = ['$locale'];
|
|||
function dateFilter($locale) {
|
||||
|
||||
|
||||
var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
|
||||
var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
|
||||
function jsonStringToDate(string){
|
||||
var match;
|
||||
if (match = string.match(R_ISO8601_STR)) {
|
||||
|
|
|
|||
|
|
@ -270,5 +270,18 @@ describe('filters', function() {
|
|||
//no time
|
||||
expect(date('2003-09-10', format)).toEqual('2003-09 00');
|
||||
});
|
||||
|
||||
it('should support different degrees of subsecond precision', function () {
|
||||
var format = 'yyyy-MM-dd';
|
||||
|
||||
expect(date('2003-09-10T13:02:03.12345678Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.1234567Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.123456Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.12345Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.1234Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.123Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.12Z', format)).toEqual('2003-09-10');
|
||||
expect(date('2003-09-10T13:02:03.1Z', format)).toEqual('2003-09-10');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue