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

Commit

Permalink
fix(dateparser): append end of format
Browse files Browse the repository at this point in the history
- Ensure trailing format string is appended to generated date string

Closes #5385
Fixes #5387
  • Loading branch information
wesleycho committed Feb 2, 2016
1 parent 3a03f29 commit 5c565df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dateparser/dateparser.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,13 @@ angular.module('ui.bootstrap.dateparser', [])
_format = _format.replace(match[1] + mapper.key, '');
}

var endStr = i === map.length - 1 ? _format : '';

if (mapper.apply) {
return str + mapper.apply.call(null, date);
return str + mapper.apply.call(null, date) + endStr;
}

return str;
return str + endStr;
}, '');
};

Expand Down
4 changes: 4 additions & 0 deletions src/dateparser/test/dateparser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ describe('date parser', function() {
expectFilter(new Date(-1955, 1, 5, 0), 'yyyy/MMMM/d/GGGG', '1955/February/5/Before Christ');
expectFilter(new Date(2013, 7, 11, 0), 'd-MM-yy GGGG', '11-08-13 Anno Domini');
});

it('should work correctly for literal text', function() {
expectFilter(new Date(2013, 10, 17, 0), 'dd.MM.yyyy foo', '17.11.2013 foo');
});
});

describe('with custom formats', function() {
Expand Down

0 comments on commit 5c565df

Please sign in to comment.