mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +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;
|
||||
if (format && isString(format)) {
|
||||
text = '';
|
||||
var parts = [];
|
||||
var parts = [], match;
|
||||
while(format) {
|
||||
parts = concat(parts, DATE_FORMATS_SPLIT.exec(format), 1);
|
||||
format = parts.pop();
|
||||
match = DATE_FORMATS_SPLIT.exec(format);
|
||||
if (match) {
|
||||
parts = concat(parts, match, 1);
|
||||
format = parts.pop();
|
||||
} else {
|
||||
parts.push(format);
|
||||
format = null;
|
||||
}
|
||||
}
|
||||
forEach(parts, function(value){
|
||||
fn = DATE_FORMATS[value];
|
||||
|
|
|
|||
|
|
@ -142,5 +142,9 @@ describe('filter', function() {
|
|||
expect(filter.date(isoString)).
|
||||
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