Skip to content

Commit 8a6b379

Browse files
committed
Fixes the date range grammar for month to support case insensitive. See #78455
1 parent 62476ad commit 8a6b379

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/elements/DateTime/DateTimeRangeGrammar.coffee

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,10 @@ class CUI.DateTimeRangeGrammar
496496
value = s.split(".")[0]
497497
else if CUI.DateTimeRangeGrammar.REGEXP_CENTURY.test(s)
498498
type = CUI.DateTimeRangeGrammar.TYPE_CENTURY
499-
value = s.split("th")[0]
500-
else if value in CUI.DateTimeRangeGrammar.MONTHS[locale]
499+
value = s.split(/th/i)[0]
500+
else if (monthIndex = CUI.DateTimeRangeGrammar.__findMonthIndex(s, locale)) >= 0
501501
type = CUI.DateTimeRangeGrammar.TYPE_MONTH
502-
value = CUI.DateTimeRangeGrammar.MONTHS[locale].indexOf(value)
502+
value = monthIndex
503503
else
504504
type = s # The type for everything else is the value.
505505

@@ -728,4 +728,14 @@ class CUI.DateTimeRangeGrammar
728728
@__toBC: (inputString) ->
729729
if inputString.match(CUI.DateTimeRangeGrammar.REGEXP_YEAR)
730730
inputString = parseInt(inputString) - 1
731-
return "-#{inputString}"
731+
return "-#{inputString}"
732+
733+
@__findMonthIndex: (value, locale) ->
734+
lowerValue = value.toLowerCase()
735+
months = CUI.DateTimeRangeGrammar.MONTHS[locale]
736+
if not months
737+
return -1
738+
for month, index in months
739+
if month.toLowerCase() == lowerValue
740+
return index
741+
return -1

0 commit comments

Comments
 (0)