Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 5c565df

Browse files
committed
fix(dateparser): append end of format
- Ensure trailing format string is appended to generated date string Closes #5385 Fixes #5387
1 parent 3a03f29 commit 5c565df

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/dateparser/dateparser.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,13 @@ angular.module('ui.bootstrap.dateparser', [])
322322
_format = _format.replace(match[1] + mapper.key, '');
323323
}
324324

325+
var endStr = i === map.length - 1 ? _format : '';
326+
325327
if (mapper.apply) {
326-
return str + mapper.apply.call(null, date);
328+
return str + mapper.apply.call(null, date) + endStr;
327329
}
328330

329-
return str;
331+
return str + endStr;
330332
}, '');
331333
};
332334

src/dateparser/test/dateparser.spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ describe('date parser', function() {
261261
expectFilter(new Date(-1955, 1, 5, 0), 'yyyy/MMMM/d/GGGG', '1955/February/5/Before Christ');
262262
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy GGGG', '11-08-13 Anno Domini');
263263
});
264+
265+
it('should work correctly for literal text', function() {
266+
expectFilter(new Date(2013, 10, 17, 0), 'dd.MM.yyyy foo', '17.11.2013 foo');
267+
});
264268
});
265269

266270
describe('with custom formats', function() {

0 commit comments

Comments
 (0)