Skip to content

Commit

Permalink
Fixes #18900 month parsing for locales with spaces in their month nam…
Browse files Browse the repository at this point in the history
…es (like Vietnamese)
  • Loading branch information
bryanforbes authored and dylans committed Nov 19, 2016
1 parent 2141e03 commit 162e403
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion date/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ function _processPattern(pattern, applyPattern, applyLiteral, applyAll){
return applyAll(chunks.join(''));
}

var widthList = ['abbr', 'wide', 'narrow'];
function _buildDateTimeRE(tokens, bundle, options, pattern){
pattern = regexp.escapeString(pattern);
if(!options.strict){ pattern = pattern.replace(" a", " ?a"); } // kludge to tolerate no space before am/pm
Expand All @@ -541,7 +542,21 @@ function _buildDateTimeRE(tokens, bundle, options, pattern){
break;
case 'M':
case 'L':
s = (l>2) ? '\\S+?' : '1[0-2]|'+p2+'[1-9]';
if(l>2){
var months = bundle[
'months-' +
(c == 'L' ? 'standAlone' : 'format') +
'-' + widthList[l-3]
].slice(0);
s = months.join('|');
if(!options.strict){
s = s.replace(/\./g, '');
//Tolerate abbreviating period in month part
s = '(?:' + s + ')\\.?';
}
}else{
s = '1[0-2]|'+p2+'[1-9]';
}
break;
case 'D':
s = '[12][0-9][0-9]|3[0-5][0-9]|36[0-6]|'+p2+'[1-9][0-9]|'+p3+'[1-9]';
Expand Down

0 comments on commit 162e403

Please sign in to comment.