System.Globalization.DateTimeFormatInfoScanner.AddDateWords C# (CSharp) Method

AddDateWords() private method

private AddDateWords ( String pattern, int index, String formatPostfix ) : int
pattern String
index int
formatPostfix String
return int
        internal int AddDateWords(String pattern, int index, String formatPostfix)
        {
            // Skip any whitespaces so we will start from a letter.
            int newIndex = SkipWhiteSpacesAndNonLetter(pattern, index);
            if (newIndex != index && formatPostfix != null)
            {
                // There are whitespaces. This will not be a postfix.
                formatPostfix = null;                
            }
            index = newIndex;

            // This is the first char added into dateWord.  
            // Skip all non-letter character.  We will add the first letter into DateWord.
            StringBuilder dateWord = new StringBuilder();      
            // We assume that date words should start with a letter. 
            // Skip anything until we see a letter.
             
            while (index < pattern.Length)
            {                         
                char ch = pattern[index];
                if (ch == '\'')
                {
                    // We have seen the end of quote.  Add the word if we do not see it before, 
                    // and break the while loop.                    
                    AddDateWordOrPostfix(formatPostfix, dateWord.ToString());
                    index++;
                    break;
                } else if (ch == '\\')
                {
                    //
                    // Escaped character.  Look ahead one character
                    //
                    
                    // Skip escaped backslash.
                    index++;
                    if (index < pattern.Length)
                    {
                        dateWord.Append(pattern[index]);
                        index++;
                    }
                } else if (Char.IsWhiteSpace(ch))
                {
                    // Found a whitespace.  We have to add the current date word/postfix.
                    AddDateWordOrPostfix(formatPostfix, dateWord.ToString());
                    if (formatPostfix != null)
                    {
                        // Done with postfix.  The rest will be regular date word.
                        formatPostfix = null;
                    }
                    // Reset the dateWord.
                    dateWord.Length = 0;
                    index++;
                } else
                {
                    dateWord.Append(ch);                                        
                    index++;
                }
            }  
            return (index);
        }