@@ -57,6 +57,7 @@ function reporter(context, config = {}) {
5757 const text = getSource ( node ) ;
5858 const chronoDate = chrono . parse ( text ) ;
5959 // ignore "今日" text
60+
6061 chronoDate . filter ( textIncludesNumber ) . forEach ( chronoDate => {
6162 const lang = detectLang ( Object . keys ( chronoDate . tags ) , preferLang ) ;
6263 if ( ! lang ) {
@@ -69,27 +70,30 @@ function reporter(context, config = {}) {
6970 try {
7071 $moment = moment ( `${ kV . year } -${ kV . month } -${ kV . day } ` , "YYYY-MM-DD" , lang ) ;
7172 } catch ( error ) {
73+ console . warn ( "Maybe textlint-rule-date-weekday-mismatch options was wrong language." , lang ) ;
7274 // parse error is ignore
7375 return ;
7476 }
7577 if ( ! $moment . isValid ( ) ) {
7678 return ;
7779 }
78- const slicedText = text . slice ( chronoDate . index ) ;
80+ // get (weekday)
81+ const startOfPairSymbol = chronoDate . text . length + chronoDate . index ;
82+ const slicedText = text . slice ( startOfPairSymbol ) ;
7983 // (match) or (match)
80- const match = slicedText . match ( / \s * ?( [ ( ( ] ) ( [ ^ ( ( ) ] + ) ( [ ) ) ] ) / ) ;
84+ const match = slicedText . match ( / ^ ( \s * ?[ ( ( ] ) ( [ ^ ( ( ) ] + ) ( [ ) ) ] ) / ) ;
8185 if ( ! match ) {
8286 return ;
8387 }
8488 const actualDateText = match [ 0 ] ;
8589 const actualTextAll = `${ chronoDate . text } ${ actualDateText } ` ;
86- const pairStartSymbol = match [ 1 ] ; // (
90+ const pairStartSymbol = match [ 1 ] ; // ( and padding-left
8791 const pairEndSymbol = match [ 3 ] ; // )
8892 const maybeWeekdayText = match [ 2 ] . trim ( ) ; // weekday
8993 // 2016年12月30日 (金曜日)
9094 // ^ ^ ^
9195 // chronoDate.index match.index pairStartSymbol.length
92- const paddingIndex = chronoDate . index + match . index + pairStartSymbol . length ;
96+ const paddingIndex = startOfPairSymbol + match . index + pairStartSymbol . length ;
9397 // format http://momentjs.com/docs/#/parsing/string-format/
9498 const weekdayPatterns = [
9599 // date-format , symbols
0 commit comments