Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(dateFilter): follow the CLDR on pattern escape sequences
When there are two single quotes "''" (quotes for clarification) that are not
part of an escape sequence, then this sequence should be handled as one single
quote. See http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns
second and forth examples

Closes #12839
  • Loading branch information
lgalfaso authored and petebacondarwin committed Jan 25, 2016
1 parent 99eeec3 commit 1ab4e44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/filter/filters.js
Expand Up @@ -613,7 +613,7 @@ function dateFilter($locale) {
forEach(parts, function(value) {
fn = DATE_FORMATS[value];
text += fn ? fn(date, $locale.DATETIME_FORMATS, dateTimezoneOffset)
: value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
: value === "''" ? "'" : value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
});

return text;
Expand Down
2 changes: 2 additions & 0 deletions test/ng/filter/filtersSpec.js
Expand Up @@ -421,6 +421,8 @@ describe('filters', function() {
it('should treat a sequence of two single quotes as a literal single quote', function() {
expect(date(midnight, "yyyy'de' 'a''dd' 'adZ' h=H:m:saZ")).
toEqual("2010de a'dd adZ 12=0:5:8AM-0500");
expect(date(midnight, "EEE, MMM d, ''yy")).
toEqual("Fri, Sep 3, '10");
});

it('should accept default formats', function() {
Expand Down

0 comments on commit 1ab4e44

Please sign in to comment.