fix(common): update DatePipe to allow closure compilation
Quote the date formats to prevent closure renaming. These are specified as strings in templates using DatePipes and also need to be quoted here.
This commit is contained in:
parent
f5c8e0989d
commit
b2b72190f8
|
@ -44,6 +44,7 @@ const DATE_FORMATS_SPLIT =
|
||||||
/((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
|
/((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
|
||||||
|
|
||||||
const PATTERN_ALIASES: {[format: string]: DateFormatterFn} = {
|
const PATTERN_ALIASES: {[format: string]: DateFormatterFn} = {
|
||||||
|
// Keys are quoted so they do not get renamed during closure compilation.
|
||||||
'yMMMdjms': datePartGetterFactory(combine([
|
'yMMMdjms': datePartGetterFactory(combine([
|
||||||
digitCondition('year', 1),
|
digitCondition('year', 1),
|
||||||
nameCondition('month', 3),
|
nameCondition('month', 3),
|
||||||
|
@ -72,48 +73,50 @@ const PATTERN_ALIASES: {[format: string]: DateFormatterFn} = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const DATE_FORMATS: {[format: string]: DateFormatterFn} = {
|
const DATE_FORMATS: {[format: string]: DateFormatterFn} = {
|
||||||
yyyy: datePartGetterFactory(digitCondition('year', 4)),
|
// Keys are quoted so they do not get renamed.
|
||||||
yy: datePartGetterFactory(digitCondition('year', 2)),
|
'yyyy': datePartGetterFactory(digitCondition('year', 4)),
|
||||||
y: datePartGetterFactory(digitCondition('year', 1)),
|
'yy': datePartGetterFactory(digitCondition('year', 2)),
|
||||||
MMMM: datePartGetterFactory(nameCondition('month', 4)),
|
'y': datePartGetterFactory(digitCondition('year', 1)),
|
||||||
MMM: datePartGetterFactory(nameCondition('month', 3)),
|
'MMMM': datePartGetterFactory(nameCondition('month', 4)),
|
||||||
MM: datePartGetterFactory(digitCondition('month', 2)),
|
'MMM': datePartGetterFactory(nameCondition('month', 3)),
|
||||||
M: datePartGetterFactory(digitCondition('month', 1)),
|
'MM': datePartGetterFactory(digitCondition('month', 2)),
|
||||||
LLLL: datePartGetterFactory(nameCondition('month', 4)),
|
'M': datePartGetterFactory(digitCondition('month', 1)),
|
||||||
L: datePartGetterFactory(nameCondition('month', 1)),
|
'LLLL': datePartGetterFactory(nameCondition('month', 4)),
|
||||||
dd: datePartGetterFactory(digitCondition('day', 2)),
|
'L': datePartGetterFactory(nameCondition('month', 1)),
|
||||||
d: datePartGetterFactory(digitCondition('day', 1)),
|
'dd': datePartGetterFactory(digitCondition('day', 2)),
|
||||||
HH: digitModifier(
|
'd': datePartGetterFactory(digitCondition('day', 1)),
|
||||||
|
'HH': digitModifier(
|
||||||
hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
|
hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
|
||||||
H: hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
|
'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
|
||||||
hh: digitModifier(
|
'hh': digitModifier(
|
||||||
hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
|
hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
|
||||||
h: hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
|
'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
|
||||||
jj: datePartGetterFactory(digitCondition('hour', 2)),
|
'jj': datePartGetterFactory(digitCondition('hour', 2)),
|
||||||
j: datePartGetterFactory(digitCondition('hour', 1)),
|
'j': datePartGetterFactory(digitCondition('hour', 1)),
|
||||||
mm: digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
|
'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
|
||||||
m: datePartGetterFactory(digitCondition('minute', 1)),
|
'm': datePartGetterFactory(digitCondition('minute', 1)),
|
||||||
ss: digitModifier(datePartGetterFactory(digitCondition('second', 2))),
|
'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
|
||||||
s: datePartGetterFactory(digitCondition('second', 1)),
|
's': datePartGetterFactory(digitCondition('second', 1)),
|
||||||
// while ISO 8601 requires fractions to be prefixed with `.` or `,`
|
// while ISO 8601 requires fractions to be prefixed with `.` or `,`
|
||||||
// we can be just safely rely on using `sss` since we currently don't support single or two digit
|
// we can be just safely rely on using `sss` since we currently don't support single or two digit
|
||||||
// fractions
|
// fractions
|
||||||
sss: datePartGetterFactory(digitCondition('second', 3)),
|
'sss': datePartGetterFactory(digitCondition('second', 3)),
|
||||||
EEEE: datePartGetterFactory(nameCondition('weekday', 4)),
|
'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
|
||||||
EEE: datePartGetterFactory(nameCondition('weekday', 3)),
|
'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
|
||||||
EE: datePartGetterFactory(nameCondition('weekday', 2)),
|
'EE': datePartGetterFactory(nameCondition('weekday', 2)),
|
||||||
E: datePartGetterFactory(nameCondition('weekday', 1)),
|
'E': datePartGetterFactory(nameCondition('weekday', 1)),
|
||||||
a: hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
|
'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
|
||||||
Z: timeZoneGetter('short'),
|
'Z': timeZoneGetter('short'),
|
||||||
z: timeZoneGetter('long'),
|
'z': timeZoneGetter('long'),
|
||||||
ww: datePartGetterFactory({}), // Week of year, padded (00-53). Week 01 is the week with the
|
'ww': datePartGetterFactory({}), // Week of year, padded (00-53). Week 01 is the week with the
|
||||||
// first Thursday of the year. not support ?
|
// first Thursday of the year. not support ?
|
||||||
w: datePartGetterFactory({}), // Week of year (0-53). Week 1 is the week with the first Thursday
|
'w':
|
||||||
|
datePartGetterFactory({}), // Week of year (0-53). Week 1 is the week with the first Thursday
|
||||||
// of the year not support ?
|
// of the year not support ?
|
||||||
G: datePartGetterFactory(nameCondition('era', 1)),
|
'G': datePartGetterFactory(nameCondition('era', 1)),
|
||||||
GG: datePartGetterFactory(nameCondition('era', 2)),
|
'GG': datePartGetterFactory(nameCondition('era', 2)),
|
||||||
GGG: datePartGetterFactory(nameCondition('era', 3)),
|
'GGG': datePartGetterFactory(nameCondition('era', 3)),
|
||||||
GGGG: datePartGetterFactory(nameCondition('era', 4))
|
'GGGG': datePartGetterFactory(nameCondition('era', 4))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue