Beispiel #1
0
            public bool Parse(string text, XsdDateTimeFlags kinds)
            {
                this.text   = text;
                this.length = text.Length;
                int start = 0;

                while ((start < this.length) && char.IsWhiteSpace(text[start]))
                {
                    start++;
                }
                if (Test(kinds, XsdDateTimeFlags.XdrDateTime | XsdDateTimeFlags.XdrDateTimeNoTz | XsdDateTimeFlags.Date | XsdDateTimeFlags.DateTime) && this.ParseDate(start))
                {
                    if ((Test(kinds, XsdDateTimeFlags.DateTime) && this.ParseChar(start + XsdDateTime.Lzyyyy_MM_dd, 'T')) && this.ParseTimeAndZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_ddT))
                    {
                        this.typeCode = XsdDateTime.DateTimeTypeCode.DateTime;
                        return(true);
                    }
                    if (Test(kinds, XsdDateTimeFlags.Date) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_dd))
                    {
                        this.typeCode = XsdDateTime.DateTimeTypeCode.Date;
                        return(true);
                    }
                    if (Test(kinds, XsdDateTimeFlags.XdrDateTime) && (this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_dd) || (this.ParseChar(start + XsdDateTime.Lzyyyy_MM_dd, 'T') && this.ParseTimeAndZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_ddT))))
                    {
                        this.typeCode = XsdDateTime.DateTimeTypeCode.XdrDateTime;
                        return(true);
                    }
                    if (Test(kinds, XsdDateTimeFlags.XdrDateTimeNoTz))
                    {
                        if (!this.ParseChar(start + XsdDateTime.Lzyyyy_MM_dd, 'T'))
                        {
                            this.typeCode = XsdDateTime.DateTimeTypeCode.XdrDateTime;
                            return(true);
                        }
                        if (this.ParseTimeAndWhitespace(start + XsdDateTime.Lzyyyy_MM_ddT))
                        {
                            this.typeCode = XsdDateTime.DateTimeTypeCode.XdrDateTime;
                            return(true);
                        }
                    }
                }
                if (Test(kinds, XsdDateTimeFlags.Time) && this.ParseTimeAndZoneAndWhitespace(start))
                {
                    this.year     = 0x770;
                    this.month    = 1;
                    this.day      = 1;
                    this.typeCode = XsdDateTime.DateTimeTypeCode.Time;
                    return(true);
                }
                if (Test(kinds, XsdDateTimeFlags.XdrTimeNoTz) && this.ParseTimeAndWhitespace(start))
                {
                    this.year     = 0x770;
                    this.month    = 1;
                    this.day      = 1;
                    this.typeCode = XsdDateTime.DateTimeTypeCode.Time;
                    return(true);
                }
                if ((Test(kinds, XsdDateTimeFlags.GYear | XsdDateTimeFlags.GYearMonth) && this.Parse4Dig(start, ref this.year)) && (1 <= this.year))
                {
                    if (((Test(kinds, XsdDateTimeFlags.GYearMonth) && this.ParseChar(start + XsdDateTime.Lzyyyy, '-')) && (this.Parse2Dig(start + XsdDateTime.Lzyyyy_, ref this.month) && (1 <= this.month))) && ((this.month <= 12) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM)))
                    {
                        this.day      = 1;
                        this.typeCode = XsdDateTime.DateTimeTypeCode.GYearMonth;
                        return(true);
                    }
                    if (Test(kinds, XsdDateTimeFlags.GYear) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy))
                    {
                        this.month    = 1;
                        this.day      = 1;
                        this.typeCode = XsdDateTime.DateTimeTypeCode.GYear;
                        return(true);
                    }
                }
                if (((Test(kinds, XsdDateTimeFlags.GMonth | XsdDateTimeFlags.GMonthDay) && this.ParseChar(start, '-')) && (this.ParseChar(start + XsdDateTime.Lz_, '-') && this.Parse2Dig(start + XsdDateTime.Lz__, ref this.month))) && ((1 <= this.month) && (this.month <= 12)))
                {
                    if (((Test(kinds, XsdDateTimeFlags.GMonthDay) && this.ParseChar(start + XsdDateTime.Lz__mm, '-')) && (this.Parse2Dig(start + XsdDateTime.Lz__mm_, ref this.day) && (1 <= this.day))) && ((this.day <= DateTime.DaysInMonth(0x770, this.month)) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lz__mm_dd)))
                    {
                        this.year     = 0x770;
                        this.typeCode = XsdDateTime.DateTimeTypeCode.GMonthDay;
                        return(true);
                    }
                    if (Test(kinds, XsdDateTimeFlags.GMonth) && (this.ParseZoneAndWhitespace(start + XsdDateTime.Lz__mm) || ((this.ParseChar(start + XsdDateTime.Lz__mm, '-') && this.ParseChar(start + XsdDateTime.Lz__mm_, '-')) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lz__mm__))))
                    {
                        this.year     = 0x770;
                        this.day      = 1;
                        this.typeCode = XsdDateTime.DateTimeTypeCode.GMonth;
                        return(true);
                    }
                }
                if (((Test(kinds, XsdDateTimeFlags.GDay) && this.ParseChar(start, '-')) && (this.ParseChar(start + XsdDateTime.Lz_, '-') && this.ParseChar(start + XsdDateTime.Lz__, '-'))) && ((this.Parse2Dig(start + XsdDateTime.Lz___, ref this.day) && (1 <= this.day)) && ((this.day <= DateTime.DaysInMonth(0x770, 1)) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lz___dd))))
                {
                    this.year     = 0x770;
                    this.month    = 1;
                    this.typeCode = XsdDateTime.DateTimeTypeCode.GDay;
                    return(true);
                }
                return(false);
            }
 public bool Parse(string text, XsdDateTimeFlags kinds)
 {
     this.text = text;
     this.length = text.Length;
     int start = 0;
     while ((start < this.length) && char.IsWhiteSpace(text[start]))
     {
         start++;
     }
     if (Test(kinds, XsdDateTimeFlags.XdrDateTime | XsdDateTimeFlags.XdrDateTimeNoTz | XsdDateTimeFlags.Date | XsdDateTimeFlags.DateTime) && this.ParseDate(start))
     {
         if ((Test(kinds, XsdDateTimeFlags.DateTime) && this.ParseChar(start + XsdDateTime.Lzyyyy_MM_dd, 'T')) && this.ParseTimeAndZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_ddT))
         {
             this.typeCode = XsdDateTime.DateTimeTypeCode.DateTime;
             return true;
         }
         if (Test(kinds, XsdDateTimeFlags.Date) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_dd))
         {
             this.typeCode = XsdDateTime.DateTimeTypeCode.Date;
             return true;
         }
         if (Test(kinds, XsdDateTimeFlags.XdrDateTime) && (this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_dd) || (this.ParseChar(start + XsdDateTime.Lzyyyy_MM_dd, 'T') && this.ParseTimeAndZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM_ddT))))
         {
             this.typeCode = XsdDateTime.DateTimeTypeCode.XdrDateTime;
             return true;
         }
         if (Test(kinds, XsdDateTimeFlags.XdrDateTimeNoTz))
         {
             if (!this.ParseChar(start + XsdDateTime.Lzyyyy_MM_dd, 'T'))
             {
                 this.typeCode = XsdDateTime.DateTimeTypeCode.XdrDateTime;
                 return true;
             }
             if (this.ParseTimeAndWhitespace(start + XsdDateTime.Lzyyyy_MM_ddT))
             {
                 this.typeCode = XsdDateTime.DateTimeTypeCode.XdrDateTime;
                 return true;
             }
         }
     }
     if (Test(kinds, XsdDateTimeFlags.Time) && this.ParseTimeAndZoneAndWhitespace(start))
     {
         this.year = 0x770;
         this.month = 1;
         this.day = 1;
         this.typeCode = XsdDateTime.DateTimeTypeCode.Time;
         return true;
     }
     if (Test(kinds, XsdDateTimeFlags.XdrTimeNoTz) && this.ParseTimeAndWhitespace(start))
     {
         this.year = 0x770;
         this.month = 1;
         this.day = 1;
         this.typeCode = XsdDateTime.DateTimeTypeCode.Time;
         return true;
     }
     if ((Test(kinds, XsdDateTimeFlags.GYear | XsdDateTimeFlags.GYearMonth) && this.Parse4Dig(start, ref this.year)) && (1 <= this.year))
     {
         if (((Test(kinds, XsdDateTimeFlags.GYearMonth) && this.ParseChar(start + XsdDateTime.Lzyyyy, '-')) && (this.Parse2Dig(start + XsdDateTime.Lzyyyy_, ref this.month) && (1 <= this.month))) && ((this.month <= 12) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy_MM)))
         {
             this.day = 1;
             this.typeCode = XsdDateTime.DateTimeTypeCode.GYearMonth;
             return true;
         }
         if (Test(kinds, XsdDateTimeFlags.GYear) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lzyyyy))
         {
             this.month = 1;
             this.day = 1;
             this.typeCode = XsdDateTime.DateTimeTypeCode.GYear;
             return true;
         }
     }
     if (((Test(kinds, XsdDateTimeFlags.GMonth | XsdDateTimeFlags.GMonthDay) && this.ParseChar(start, '-')) && (this.ParseChar(start + XsdDateTime.Lz_, '-') && this.Parse2Dig(start + XsdDateTime.Lz__, ref this.month))) && ((1 <= this.month) && (this.month <= 12)))
     {
         if (((Test(kinds, XsdDateTimeFlags.GMonthDay) && this.ParseChar(start + XsdDateTime.Lz__mm, '-')) && (this.Parse2Dig(start + XsdDateTime.Lz__mm_, ref this.day) && (1 <= this.day))) && ((this.day <= DateTime.DaysInMonth(0x770, this.month)) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lz__mm_dd)))
         {
             this.year = 0x770;
             this.typeCode = XsdDateTime.DateTimeTypeCode.GMonthDay;
             return true;
         }
         if (Test(kinds, XsdDateTimeFlags.GMonth) && (this.ParseZoneAndWhitespace(start + XsdDateTime.Lz__mm) || ((this.ParseChar(start + XsdDateTime.Lz__mm, '-') && this.ParseChar(start + XsdDateTime.Lz__mm_, '-')) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lz__mm__))))
         {
             this.year = 0x770;
             this.day = 1;
             this.typeCode = XsdDateTime.DateTimeTypeCode.GMonth;
             return true;
         }
     }
     if (((Test(kinds, XsdDateTimeFlags.GDay) && this.ParseChar(start, '-')) && (this.ParseChar(start + XsdDateTime.Lz_, '-') && this.ParseChar(start + XsdDateTime.Lz__, '-'))) && ((this.Parse2Dig(start + XsdDateTime.Lz___, ref this.day) && (1 <= this.day)) && ((this.day <= DateTime.DaysInMonth(0x770, 1)) && this.ParseZoneAndWhitespace(start + XsdDateTime.Lz___dd))))
     {
         this.year = 0x770;
         this.month = 1;
         this.typeCode = XsdDateTime.DateTimeTypeCode.GDay;
         return true;
     }
     return false;
 }