Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1ab4e44

Browse files
lgalfasopetebacondarwin
authored andcommitted
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
1 parent 99eeec3 commit 1ab4e44

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ng/filter/filters.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ function dateFilter($locale) {
613613
forEach(parts, function(value) {
614614
fn = DATE_FORMATS[value];
615615
text += fn ? fn(date, $locale.DATETIME_FORMATS, dateTimezoneOffset)
616-
: value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
616+
: value === "''" ? "'" : value.replace(/(^'|'$)/g, '').replace(/''/g, "'");
617617
});
618618

619619
return text;

test/ng/filter/filtersSpec.js

+2
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ describe('filters', function() {
421421
it('should treat a sequence of two single quotes as a literal single quote', function() {
422422
expect(date(midnight, "yyyy'de' 'a''dd' 'adZ' h=H:m:saZ")).
423423
toEqual("2010de a'dd adZ 12=0:5:8AM-0500");
424+
expect(date(midnight, "EEE, MMM d, ''yy")).
425+
toEqual("Fri, Sep 3, '10");
424426
});
425427

426428
it('should accept default formats', function() {

0 commit comments

Comments
 (0)