Skip to content
Permalink
Browse files

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 Sep 14, 2015
1 parent 6a953bb commit f476060de6cc016380c0343490a184543f853652
Showing with 3 additions and 1 deletion.
  1. +1 −1 src/ng/filter/filters.js
  2. +2 −0 test/ng/filter/filtersSpec.js
@@ -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;
@@ -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() {

0 comments on commit f476060

Please sign in to comment.
You can’t perform that action at this time.