コード例 #1
0
        bool TryParseMonth(ICharSequence txt, int tokenStart, int tokenEnd)
        {
            int len = tokenEnd - tokenStart;

            if (len != 3)
            {
                return(false);
            }

            char monthChar1 = AsciiString.ToLowerCase(txt[tokenStart]);
            char monthChar2 = AsciiString.ToLowerCase(txt[tokenStart + 1]);
            char monthChar3 = AsciiString.ToLowerCase(txt[tokenStart + 2]);

            if (monthChar1 == 'j' && monthChar2 == 'a' && monthChar3 == 'n')
            {
                this.month = 1;
            }
            else if (monthChar1 == 'f' && monthChar2 == 'e' && monthChar3 == 'b')
            {
                this.month = 2;
            }
            else if (monthChar1 == 'm' && monthChar2 == 'a' && monthChar3 == 'r')
            {
                this.month = 3;
            }
            else if (monthChar1 == 'a' && monthChar2 == 'p' && monthChar3 == 'r')
            {
                this.month = 4;
            }
            else if (monthChar1 == 'm' && monthChar2 == 'a' && monthChar3 == 'y')
            {
                this.month = 5;
            }
            else if (monthChar1 == 'j' && monthChar2 == 'u' && monthChar3 == 'n')
            {
                this.month = 6;
            }
            else if (monthChar1 == 'j' && monthChar2 == 'u' && monthChar3 == 'l')
            {
                this.month = 7;
            }
            else if (monthChar1 == 'a' && monthChar2 == 'u' && monthChar3 == 'g')
            {
                this.month = 8;
            }
            else if (monthChar1 == 's' && monthChar2 == 'e' && monthChar3 == 'p')
            {
                this.month = 9;
            }
            else if (monthChar1 == 'o' && monthChar2 == 'c' && monthChar3 == 't')
            {
                this.month = 10;
            }
            else if (monthChar1 == 'n' && monthChar2 == 'o' && monthChar3 == 'v')
            {
                this.month = 11;
            }
            else if (monthChar1 == 'd' && monthChar2 == 'e' && monthChar3 == 'c')
            {
                this.month = 12;
            }
            else
            {
                return(false);
            }

            return(true);
        }