mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-28 07:23:59 +00:00
Fixed filter.date, so it parses format ending with non-replaced string
Closes #159
This commit is contained in:
parent
0a6cf70deb
commit
aab3df7aea
2 changed files with 13 additions and 3 deletions
|
|
@ -217,10 +217,16 @@ angularFilter.date = function(date, format) {
|
||||||
var text = date.toLocaleDateString(), fn;
|
var text = date.toLocaleDateString(), fn;
|
||||||
if (format && isString(format)) {
|
if (format && isString(format)) {
|
||||||
text = '';
|
text = '';
|
||||||
var parts = [];
|
var parts = [], match;
|
||||||
while(format) {
|
while(format) {
|
||||||
parts = concat(parts, DATE_FORMATS_SPLIT.exec(format), 1);
|
match = DATE_FORMATS_SPLIT.exec(format);
|
||||||
format = parts.pop();
|
if (match) {
|
||||||
|
parts = concat(parts, match, 1);
|
||||||
|
format = parts.pop();
|
||||||
|
} else {
|
||||||
|
parts.push(format);
|
||||||
|
format = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
forEach(parts, function(value){
|
forEach(parts, function(value){
|
||||||
fn = DATE_FORMATS[value];
|
fn = DATE_FORMATS[value];
|
||||||
|
|
|
||||||
|
|
@ -142,5 +142,9 @@ describe('filter', function() {
|
||||||
expect(filter.date(isoString)).
|
expect(filter.date(isoString)).
|
||||||
toEqual(angular.String.toDate(isoString).toLocaleDateString());
|
toEqual(angular.String.toDate(isoString).toLocaleDateString());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse format ending with non-replaced string', function() {
|
||||||
|
expect(filter.date(morning, 'yy/xxx')).toEqual('10/xxx');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue