////////////////////////////////////////////////////////////////////////////
        //
        // Given a date format pattern, scan for date word or postfix.
        //
        // A date word should be always put in a single quoted string.  And it will
        // start from a letter, so whitespace and symbols will be ignored before
        // the first letter.
        //
        // Examples of date word:
        //  'de' in es-SP: dddd, dd' de 'MMMM' de 'yyyy
        //  "\x0443." in bg-BG: dd.M.yyyy '\x0433.'
        //
        // Example of postfix:
        //  month postfix: 
        //      "ta" in fi-FI: d. MMMM'ta 'yyyy
        //  Currently, only month postfix is supported.
        //
        // Usage:
        //  Always call this with Framework-style pattern, instead of Windows style pattern.
        //  Windows style pattern uses '' for single quote, while .NET uses \'
        //
        ////////////////////////////////////////////////////////////////////////////        
        internal void ScanDateWord(String pattern)
        {

            // Check if we have found all of the year/month/day pattern.
            m_ymdFlags = FoundDatePattern.None;
            
            int i = 0;
            while (i < pattern.Length)
            {
                char ch = pattern[i];  
                int chCount;
                
                switch (ch)
                {
                    case '\'':
                        // Find a beginning quote.  Search until the end quote.
                        i = AddDateWords(pattern, i+1, null);
                        break;
                    case 'M':
                        i = ScanRepeatChar(pattern, 'M', i, out chCount);
                        if (chCount >= 4)
                        {
                            if (i < pattern.Length && pattern[i] == '\'')
                            {
                                i = AddDateWords(pattern, i+1, "MMMM");
                            }
                        }
                        m_ymdFlags |= FoundDatePattern.FoundMonthPatternFlag;
                        break;
                    case 'y':
                        i = ScanRepeatChar(pattern, 'y', i, out chCount);
                        m_ymdFlags |= FoundDatePattern.FoundYearPatternFlag;
                        break;
                    case 'd':
                        i = ScanRepeatChar(pattern, 'd', i, out chCount);
                        if (chCount <= 2)
                        {
                            // Only count "d" & "dd".
                            // ddd, dddd are day names.  Do not count them.
                            m_ymdFlags |= FoundDatePattern.FoundDayPatternFlag;
                        }
                        break;
                    case '\\':
                        // Found a escaped char not in a quoted string.  Skip the current backslash
                        // and its next character.
                        i += 2;
                        break;
                    case '.':
                        if (m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag)
                        {
                            // If we find a dot immediately after the we have seen all of the y, m, d pattern.
                            // treat it as a ignroable symbol.  Check for comments in AddIgnorableSymbols for
                            // more details.
                            AddIgnorableSymbols(".");
                            m_ymdFlags = FoundDatePattern.None;
                        }
                        i++;
                        break;
                    default:
                        if (m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag && !Char.IsWhiteSpace(ch))
                        {
                            // We are not seeing "." after YMD. Clear the flag.
                            m_ymdFlags = FoundDatePattern.None;
                        }
                        // We are not in quote.  Skip the current character.
                        i++;
                        break;
                }                        
            }            
        }
Esempio n. 2
0
        internal void ScanDateWord(string pattern)
        {
            this.m_ymdFlags = FoundDatePattern.None;
            int index = 0;

            while (index < pattern.Length)
            {
                int  num2;
                char c = pattern[index];
                switch (c)
                {
                case '\\':
                {
                    index += 2;
                    continue;
                }

                case 'd':
                {
                    index = ScanRepeatChar(pattern, 'd', index, out num2);
                    if (num2 <= 2)
                    {
                        this.m_ymdFlags |= FoundDatePattern.FoundDayPatternFlag;
                    }
                    continue;
                }

                case 'y':
                {
                    index            = ScanRepeatChar(pattern, 'y', index, out num2);
                    this.m_ymdFlags |= FoundDatePattern.FoundYearPatternFlag;
                    continue;
                }

                case '\'':
                {
                    index = this.AddDateWords(pattern, index + 1, null);
                    continue;
                }

                case '.':
                {
                    if (this.m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag)
                    {
                        this.AddIgnorableSymbols(".");
                        this.m_ymdFlags = FoundDatePattern.None;
                    }
                    index++;
                    continue;
                }

                case 'M':
                {
                    index = ScanRepeatChar(pattern, 'M', index, out num2);
                    if (((num2 >= 4) && (index < pattern.Length)) && (pattern[index] == '\''))
                    {
                        index = this.AddDateWords(pattern, index + 1, "MMMM");
                    }
                    this.m_ymdFlags |= FoundDatePattern.FoundMonthPatternFlag;
                    continue;
                }
                }
                if ((this.m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag) && !char.IsWhiteSpace(c))
                {
                    this.m_ymdFlags = FoundDatePattern.None;
                }
                index++;
            }
        }
Esempio n. 3
0
        ////////////////////////////////////////////////////////////////////////////
        //
        // Given a date format pattern, scan for date word or postfix.
        //
        // A date word should be always put in a single quoted string.  And it will
        // start from a letter, so whitespace and symbols will be ignored before
        // the first letter.
        //
        // Examples of date word:
        //  'de' in es-SP: dddd, dd' de 'MMMM' de 'yyyy
        //  "\x0443." in bg-BG: dd.M.yyyy '\x0433.'
        //
        // Example of postfix:
        //  month postfix:
        //      "ta" in fi-FI: d. MMMM'ta 'yyyy
        //  Currently, only month postfix is supported.
        //
        // Usage:
        //  Always call this with Framework-style pattern, instead of Windows style pattern.
        //  Windows style pattern uses '' for single quote, while .NET uses \'
        //
        ////////////////////////////////////////////////////////////////////////////
        internal void ScanDateWord(String pattern)
        {
            // Check if we have found all of the year/month/day pattern.
            _ymdFlags = FoundDatePattern.None;

            int i = 0;

            while (i < pattern.Length)
            {
                char ch = pattern[i];
                int  chCount;

                switch (ch)
                {
                case '\'':
                    // Find a beginning quote.  Search until the end quote.
                    i = AddDateWords(pattern, i + 1, null);
                    break;

                case 'M':
                    i = ScanRepeatChar(pattern, 'M', i, out chCount);
                    if (chCount >= 4)
                    {
                        if (i < pattern.Length && pattern[i] == '\'')
                        {
                            i = AddDateWords(pattern, i + 1, "MMMM");
                        }
                    }
                    _ymdFlags |= FoundDatePattern.FoundMonthPatternFlag;
                    break;

                case 'y':
                    i          = ScanRepeatChar(pattern, 'y', i, out chCount);
                    _ymdFlags |= FoundDatePattern.FoundYearPatternFlag;
                    break;

                case 'd':
                    i = ScanRepeatChar(pattern, 'd', i, out chCount);
                    if (chCount <= 2)
                    {
                        // Only count "d" & "dd".
                        // ddd, dddd are day names.  Do not count them.
                        _ymdFlags |= FoundDatePattern.FoundDayPatternFlag;
                    }
                    break;

                case '\\':
                    // Found a escaped char not in a quoted string.  Skip the current backslash
                    // and its next character.
                    i += 2;
                    break;

                case '.':
                    if (_ymdFlags == FoundDatePattern.FoundYMDPatternFlag)
                    {
                        // If we find a dot immediately after the we have seen all of the y, m, d pattern.
                        // treat it as a ignroable symbol.  Check for comments in AddIgnorableSymbols for
                        // more details.
                        AddIgnorableSymbols(".");
                        _ymdFlags = FoundDatePattern.None;
                    }
                    i++;
                    break;

                default:
                    if (_ymdFlags == FoundDatePattern.FoundYMDPatternFlag && !Char.IsWhiteSpace(ch))
                    {
                        // We are not seeing "." after YMD. Clear the flag.
                        _ymdFlags = FoundDatePattern.None;
                    }
                    // We are not in quote.  Skip the current character.
                    i++;
                    break;
                }
            }
        }
 internal void ScanDateWord(string pattern)
 {
     this.m_ymdFlags = FoundDatePattern.None;
     int index = 0;
     while (index < pattern.Length)
     {
         int num2;
         char c = pattern[index];
         switch (c)
         {
             case '\\':
             {
                 index += 2;
                 continue;
             }
             case 'd':
             {
                 index = ScanRepeatChar(pattern, 'd', index, out num2);
                 if (num2 <= 2)
                 {
                     this.m_ymdFlags |= FoundDatePattern.FoundDayPatternFlag;
                 }
                 continue;
             }
             case 'y':
             {
                 index = ScanRepeatChar(pattern, 'y', index, out num2);
                 this.m_ymdFlags |= FoundDatePattern.FoundYearPatternFlag;
                 continue;
             }
             case '\'':
             {
                 index = this.AddDateWords(pattern, index + 1, null);
                 continue;
             }
             case '.':
             {
                 if (this.m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag)
                 {
                     this.AddIgnorableSymbols(".");
                     this.m_ymdFlags = FoundDatePattern.None;
                 }
                 index++;
                 continue;
             }
             case 'M':
             {
                 index = ScanRepeatChar(pattern, 'M', index, out num2);
                 if (((num2 >= 4) && (index < pattern.Length)) && (pattern[index] == '\''))
                 {
                     index = this.AddDateWords(pattern, index + 1, "MMMM");
                 }
                 this.m_ymdFlags |= FoundDatePattern.FoundMonthPatternFlag;
                 continue;
             }
         }
         if ((this.m_ymdFlags == FoundDatePattern.FoundYMDPatternFlag) && !char.IsWhiteSpace(c))
         {
             this.m_ymdFlags = FoundDatePattern.None;
         }
         index++;
     }
 }