mixedPieces = [],
i,
l,
+ erasName,
+ erasAbbr,
+ erasNarrow,
eras = this.eras();
for (i = 0, l = eras.length; i < l; ++i) {
- namePieces.push(regexEscape(eras[i].name));
- abbrPieces.push(regexEscape(eras[i].abbr));
- narrowPieces.push(regexEscape(eras[i].narrow));
-
- mixedPieces.push(regexEscape(eras[i].name));
- mixedPieces.push(regexEscape(eras[i].abbr));
- mixedPieces.push(regexEscape(eras[i].narrow));
+ erasName = regexEscape(eras[i].name);
+ erasAbbr = regexEscape(eras[i].abbr);
+ erasNarrow = regexEscape(eras[i].narrow);
+
+ namePieces.push(erasName);
+ abbrPieces.push(erasAbbr);
+ narrowPieces.push(erasNarrow);
+ mixedPieces.push(erasName);
+ mixedPieces.push(erasAbbr);
+ mixedPieces.push(erasNarrow);
}
this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
longPieces = [],
mixedPieces = [],
i,
- mom;
+ mom,
+ shortP,
+ longP;
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
mom = createUTC([2000, i]);
- shortPieces.push(this.monthsShort(mom, ''));
- longPieces.push(this.months(mom, ''));
- mixedPieces.push(this.months(mom, ''));
- mixedPieces.push(this.monthsShort(mom, ''));
+ shortP = regexEscape(this.monthsShort(mom, ''));
+ longP = regexEscape(this.months(mom, ''));
+ shortPieces.push(shortP);
+ longPieces.push(longP);
+ mixedPieces.push(longP);
+ mixedPieces.push(shortP);
}
// Sorting makes sure if one month (or abbr) is a prefix of another it
// will match the longer piece.
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
- for (i = 0; i < 12; i++) {
- shortPieces[i] = regexEscape(shortPieces[i]);
- longPieces[i] = regexEscape(longPieces[i]);
- }
- for (i = 0; i < 24; i++) {
- mixedPieces[i] = regexEscape(mixedPieces[i]);
- }
this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
this._monthsShortRegex = this._monthsRegex;