当前位置: 首页>>代码示例>>C#>>正文


C# __DTString.GetNext方法代码示例

本文整理汇总了C#中System.__DTString.GetNext方法的典型用法代码示例。如果您正苦于以下问题:C# __DTString.GetNext方法的具体用法?C# __DTString.GetNext怎么用?C# __DTString.GetNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.__DTString的用法示例。


在下文中一共展示了__DTString.GetNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryParse

 internal static unsafe bool TryParse(string s, DateTimeFormatInfo dtfi, DateTimeStyles styles, ref DateTimeResult result)
 {
     DateTime time;
     if (s == null)
     {
         result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "s");
         return false;
     }
     if (s.Length == 0)
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
         return false;
     }
     DS bEGIN = DS.BEGIN;
     bool flag = false;
     DateTimeToken dtok = new DateTimeToken {
         suffix = TokenType.SEP_Unk
     };
     DateTimeRawInfo raw = new DateTimeRawInfo();
     int* numberBuffer = stackalloc int[3];
     raw.Init(numberBuffer);
     result.calendar = dtfi.Calendar;
     result.era = 0;
     __DTString str = new __DTString(s, dtfi);
     str.GetNext();
     do
     {
         if (!Lex(bEGIN, ref str, ref dtok, ref raw, ref result, ref dtfi))
         {
             return false;
         }
         if (dtok.dtt != DTT.Unk)
         {
             if (dtok.suffix != TokenType.SEP_Unk)
             {
                 if (!ProcessDateTimeSuffix(ref result, ref raw, ref dtok))
                 {
                     result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                     return false;
                 }
                 dtok.suffix = TokenType.SEP_Unk;
             }
             if (dtok.dtt == DTT.NumLocalTimeMark)
             {
                 switch (bEGIN)
                 {
                     case DS.D_YNd:
                     case DS.D_YN:
                         return ParseISO8601(ref raw, ref str, styles, ref result);
                 }
                 result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                 return false;
             }
             bEGIN = dateParsingStates[(int) bEGIN][(int) dtok.dtt];
             if (bEGIN == DS.ERROR)
             {
                 result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                 return false;
             }
             if (bEGIN > DS.ERROR)
             {
                 if ((dtfi.FormatFlags & DateTimeFormatFlags.UseHebrewRule) != DateTimeFormatFlags.None)
                 {
                     if (!ProcessHebrewTerminalState(bEGIN, ref result, ref styles, ref raw, dtfi))
                     {
                         return false;
                     }
                 }
                 else if (!ProcessTerminaltState(bEGIN, ref result, ref styles, ref raw, dtfi))
                 {
                     return false;
                 }
                 flag = true;
                 bEGIN = DS.BEGIN;
             }
         }
     }
     while (((dtok.dtt != DTT.End) && (dtok.dtt != DTT.NumEnd)) && (dtok.dtt != DTT.MonthEnd));
     if (!flag)
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
         return false;
     }
     AdjustTimeMark(dtfi, ref raw);
     if (!AdjustHour(ref result.Hour, raw.timeMark))
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
         return false;
     }
     bool bTimeOnly = ((result.Year == -1) && (result.Month == -1)) && (result.Day == -1);
     if (!CheckDefaultDateTime(ref result, ref result.calendar, styles))
     {
         return false;
     }
     if (!result.calendar.TryToDateTime(result.Year, result.Month, result.Day, result.Hour, result.Minute, result.Second, 0, result.era, out time))
     {
         result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
         return false;
     }
     if (raw.fraction > 0.0)
//.........这里部分代码省略.........
开发者ID:randomize,项目名称:VimConfig,代码行数:101,代码来源:DateTimeParse.cs

示例2: ParseByFormat

		private static bool ParseByFormat(ref __DTString str, ref __DTString format, ref ParsingInfo parseInfo, DateTimeFormatInfo dtfi, ref DateTimeResult result)
		{
			int num = 0;
			int newValue = 0;
			int newValue2 = 0;
			int newValue3 = 0;
			int newValue4 = 0;
			int newValue5 = 0;
			int newValue6 = 0;
			int newValue7 = 0;
			double num2 = 0.0;
			DateTimeParse.TM tM = DateTimeParse.TM.AM;
			char @char = format.GetChar();
			char c = @char;
			if (c <= 'H')
			{
				if (c <= '\'')
				{
					if (c != '"')
					{
						switch (c)
						{
							case '%':
							{
								if (format.Index >= format.Value.Length - 1 || format.Value[format.Index + 1] == '%')
								{
									result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier", null);
									return false;
								}
								return true;
							}
							case '&':
							{
								goto IL_991;
							}
							case '\'':
							{
								break;
							}
							default:
							{
								goto IL_991;
							}
						}
					}
					StringBuilder stringBuilder = new StringBuilder();
					if (!DateTimeParse.TryParseQuoteString(format.Value, format.Index, stringBuilder, out num))
					{
						result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadQuote", @char);
						return false;
					}
					format.Index += num - 1;
					string text = stringBuilder.ToString();
					for (int i = 0; i < text.Length; i++)
					{
						if (text[i] == ' ' && parseInfo.fAllowInnerWhite)
						{
							str.SkipWhiteSpaces();
						}
						else
						{
							if (!str.Match(text[i]))
							{
								result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
								return false;
							}
						}
					}
					if ((result.flags & ParseFlags.CaptureOffset) == (ParseFlags)0)
					{
						return true;
					}
					if ((result.flags & ParseFlags.Rfc1123Pattern) != (ParseFlags)0 && text == "GMT")
					{
						result.flags |= ParseFlags.TimeZoneUsed;
						result.timeZoneOffset = TimeSpan.Zero;
						return true;
					}
					if ((result.flags & ParseFlags.UtcSortPattern) != (ParseFlags)0 && text == "Z")
					{
						result.flags |= ParseFlags.TimeZoneUsed;
						result.timeZoneOffset = TimeSpan.Zero;
						return true;
					}
					return true;
				}
				else
				{
					switch (c)
					{
						case '.':
						{
							if (str.Match(@char))
							{
								return true;
							}
							if (format.GetNext() && format.Match('F'))
							{
								format.GetRepeatCount();
								return true;
//.........这里部分代码省略.........
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:101,代码来源:DateTimeParse.cs

示例3: ParseFraction

		private static bool ParseFraction(ref __DTString str, out double result)
		{
			result = 0.0;
			double num = 0.1;
			int num2 = 0;
			char current;
			while (str.GetNext() && DateTimeParse.IsDigit(current = str.m_current))
			{
				result += (double)(current - '0') * num;
				num *= 0.1;
				num2++;
			}
			return num2 > 0;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:14,代码来源:DateTimeParse.cs

示例4: MatchDayName

		private static bool MatchDayName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result)
		{
			int num = 0;
			result = -1;
			if (str.GetNext())
			{
				for (DayOfWeek dayOfWeek = DayOfWeek.Sunday; dayOfWeek <= DayOfWeek.Saturday; dayOfWeek += DayOfWeek.Monday)
				{
					string dayName = dtfi.GetDayName(dayOfWeek);
					int length = dayName.Length;
					if ((dtfi.HasSpacesInDayNames ? str.MatchSpecifiedWords(dayName, false, ref length) : str.MatchSpecifiedWord(dayName)) && length > num)
					{
						num = length;
						result = (int)dayOfWeek;
					}
				}
			}
			if (result >= 0)
			{
				str.Index += num - 1;
				return true;
			}
			return false;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:24,代码来源:DateTimeParse.cs

示例5: MatchTimeMark

		private static bool MatchTimeMark(ref __DTString str, DateTimeFormatInfo dtfi, ref DateTimeParse.TM result)
		{
			result = DateTimeParse.TM.NotSet;
			if (dtfi.AMDesignator.Length == 0)
			{
				result = DateTimeParse.TM.AM;
			}
			if (dtfi.PMDesignator.Length == 0)
			{
				result = DateTimeParse.TM.PM;
			}
			if (str.GetNext())
			{
				string text = dtfi.AMDesignator;
				if (text.Length > 0 && str.MatchSpecifiedWord(text))
				{
					str.Index += text.Length - 1;
					result = DateTimeParse.TM.AM;
					return true;
				}
				text = dtfi.PMDesignator;
				if (text.Length > 0 && str.MatchSpecifiedWord(text))
				{
					str.Index += text.Length - 1;
					result = DateTimeParse.TM.PM;
					return true;
				}
				str.Index--;
			}
			return result != -1;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:31,代码来源:DateTimeParse.cs

示例6: ParseISO8601

		private static bool ParseISO8601(ref DateTimeRawInfo raw, ref __DTString str, DateTimeStyles styles, ref DateTimeResult result)
		{
			if (raw.year >= 0 && raw.GetNumber(0) >= 0)
			{
				raw.GetNumber(1);
			}
			str.Index--;
			int second = 0;
			double num = 0.0;
			str.SkipWhiteSpaces();
			int hour;
			if (!DateTimeParse.ParseDigits(ref str, 2, out hour))
			{
				result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
				return false;
			}
			str.SkipWhiteSpaces();
			if (!str.Match(':'))
			{
				result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
				return false;
			}
			str.SkipWhiteSpaces();
			int minute;
			if (!DateTimeParse.ParseDigits(ref str, 2, out minute))
			{
				result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
				return false;
			}
			str.SkipWhiteSpaces();
			if (str.Match(':'))
			{
				str.SkipWhiteSpaces();
				if (!DateTimeParse.ParseDigits(ref str, 2, out second))
				{
					result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
					return false;
				}
				if (str.Match('.'))
				{
					if (!DateTimeParse.ParseFraction(ref str, out num))
					{
						result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
						return false;
					}
					str.Index--;
				}
				str.SkipWhiteSpaces();
			}
			if (str.GetNext())
			{
				char @char = str.GetChar();
				if (@char == '+' || @char == '-')
				{
					result.flags |= ParseFlags.TimeZoneUsed;
					if (!DateTimeParse.ParseTimeZone(ref str, ref result.timeZoneOffset))
					{
						result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
						return false;
					}
				}
				else
				{
					if (@char == 'Z' || @char == 'z')
					{
						result.flags |= ParseFlags.TimeZoneUsed;
						result.timeZoneOffset = TimeSpan.Zero;
						result.flags |= ParseFlags.TimeZoneUtc;
					}
					else
					{
						str.Index--;
					}
				}
				str.SkipWhiteSpaces();
				if (str.Match('#'))
				{
					if (!DateTimeParse.VerifyValidPunctuation(ref str))
					{
						result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
						return false;
					}
					str.SkipWhiteSpaces();
				}
				if (str.Match('\0') && !DateTimeParse.VerifyValidPunctuation(ref str))
				{
					result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
					return false;
				}
				if (str.GetNext())
				{
					result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
					return false;
				}
			}
			Calendar defaultInstance = GregorianCalendar.GetDefaultInstance();
			DateTime parsedDate;
			if (!defaultInstance.TryToDateTime(raw.year, raw.GetNumber(0), raw.GetNumber(1), hour, minute, second, 0, result.era, out parsedDate))
			{
				result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
//.........这里部分代码省略.........
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:101,代码来源:DateTimeParse.cs

示例7: ParseSign

		private static bool ParseSign(ref __DTString str, ref bool result)
		{
			if (!str.GetNext())
			{
				return false;
			}
			char @char = str.GetChar();
			if (@char == '+')
			{
				result = true;
				return true;
			}
			if (@char == '-')
			{
				result = false;
				return true;
			}
			return false;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:19,代码来源:DateTimeParse.cs

示例8: ParseSign

        /*=================================ParseSign==================================
        **Action: Parse a positive or a negative sign.
        **Returns:      true if postive sign.  flase if negative sign.
        **Arguments:    str: a __DTString.  The parsing will start from the
        **              next character after str.Index.
        **Exceptions:   FormatException if end of string is encountered or a sign
        **              symbol is not found.
        ==============================================================================*/

        private static bool ParseSign(ref __DTString str, ref bool result) {
            if (!str.GetNext()) {
                // A sign symbol ('+' or '-') is expected. However, end of string is encountered.
                return false;
            }
            char ch = str.GetChar();
            if (ch == '+') {
                result = true;
                return (true);
            } else if (ch == '-') {
                result = false;
                return (true);
            }
            // A sign symbol ('+' or '-') is expected.
            return false;
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:25,代码来源:DateTimeParse.cs

示例9: MatchMonthName

        /*=================================MatchMonthName==================================
        **Action: Parse the month name from string starting at str.Index.
        **Returns: A value from 1 to 12 indicating the first month to the twelveth month.
        **Arguments:    str: a __DTString.  The parsing will start from the
        **              next character after str.Index.
        **Exceptions: FormatException if a month name can not be found.
        ==============================================================================*/

        private static bool MatchMonthName(ref __DTString str, DateTimeFormatInfo dtfi, ref int result) {
            int maxMatchStrLen = 0;
            result = -1;
            if (str.GetNext()) {
                //
                // Scan the month names (note that some calendars has 13 months) and find
                // the matching month name which has the max string length.
                // We need to do this because some cultures (e.g. "vi-VN") which have
                // month names with the same prefix.
                //
                int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12: 13);
                for (int i = 1; i <= monthsInYear; i++) {
                    String searchStr = dtfi.GetMonthName(i);
                    int matchStrLen = searchStr.Length;
                    if ( dtfi.HasSpacesInMonthNames
                            ? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen)
                            : str.MatchSpecifiedWord(searchStr)) {
                        if (matchStrLen > maxMatchStrLen) {
                            maxMatchStrLen = matchStrLen;
                            result = i;
                        }
                    }
                }

                // Search genitive form.
                if ((dtfi.FormatFlags & DateTimeFormatFlags.UseGenitiveMonth) != 0) {
                    int tempResult = str.MatchLongestWords(dtfi.MonthGenitiveNames, ref maxMatchStrLen);
                    // We found a longer match in the genitive month name.  Use this as the result.
                    // The result from MatchLongestWords is 0 ~ length of word array.
                    // So we increment the result by one to become the month value.
                    if (tempResult >= 0) {
                        result = tempResult + 1;
                    }
                }

                // Search leap year form.
                if ((dtfi.FormatFlags & DateTimeFormatFlags.UseLeapYearMonth) != 0) {
                    int tempResult = str.MatchLongestWords(dtfi.internalGetLeapYearMonthNames(), ref maxMatchStrLen);
                    // We found a longer match in the leap year month name.  Use this as the result.
                    // The result from MatchLongestWords is 0 ~ length of word array.
                    // So we increment the result by one to become the month value.
                    if (tempResult >= 0) {
                        result = tempResult + 1;
                    }
                }


            }

            if (result > 0) {
                str.Index += (maxMatchStrLen - 1);
                return (true);
            }
            return false;
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:63,代码来源:DateTimeParse.cs

示例10: ParseISO8601

        //
        // Parse the ISO8601 format string found during Parse();
        //
        //
        private static bool ParseISO8601(ref DateTimeRawInfo raw, ref __DTString str, DateTimeStyles styles, ref DateTimeResult result) {
            if (raw.year < 0 || raw.GetNumber(0) < 0 || raw.GetNumber(1) < 0) {
            }
            str.Index--;
            int hour, minute;
            int second = 0;
            double partSecond = 0;

            str.SkipWhiteSpaces();
            if (!ParseDigits(ref str, 2, out hour)) {
                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                return false;
            }
            str.SkipWhiteSpaces();
            if (!str.Match(':')) {
                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                return false;
            }
            str.SkipWhiteSpaces();
            if (!ParseDigits(ref str, 2, out minute)) {
                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                return false;
            }
            str.SkipWhiteSpaces();
            if (str.Match(':')) {
                str.SkipWhiteSpaces();
                if (!ParseDigits(ref str, 2, out second)) {
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;
                }
                if (str.Match('.')) {
                    if (!ParseFraction(ref str, out partSecond)) {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return false;
                    }
                    str.Index--;
                }
                str.SkipWhiteSpaces();
            }
            if (str.GetNext()) {
                char ch = str.GetChar();
                if (ch == '+' || ch == '-') {
                    result.flags |= ParseFlags.TimeZoneUsed;
                    if (!ParseTimeZone(ref str, ref result.timeZoneOffset)) {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return false;
                    }
                } else if (ch == 'Z' || ch == 'z') {
                    result.flags |= ParseFlags.TimeZoneUsed;
                    result.timeZoneOffset = TimeSpan.Zero;
                    result.flags |= ParseFlags.TimeZoneUtc;
                } else {
                    str.Index--;
                }
                str.SkipWhiteSpaces();
                if (str.Match('#')) {
                    if (!VerifyValidPunctuation(ref str)) {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return false;                        
                    }
                    str.SkipWhiteSpaces();
                }
                if (str.Match('\0')) {
                    if (!VerifyValidPunctuation(ref str)) {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return false;                        
                    }
                }
                if (str.GetNext()) {                
                    // If this is true, there were non-white space characters remaining in the DateTime
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;
                }
            }

            DateTime time;
            Calendar calendar = GregorianCalendar.GetDefaultInstance();
            if (!calendar.TryToDateTime(raw.year, raw.GetNumber(0), raw.GetNumber(1),
                    hour, minute, second, 0, result.era, out time)) {
                result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
                return false;
            }
            
            time = time.AddTicks((long)Math.Round(partSecond * Calendar.TicksPerSecond));
            result.parsedDate = time;
            if (!DetermineTimeZoneAdjustments(ref result, styles, false)) {
                return false;
            }
            return true;
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:94,代码来源:DateTimeParse.cs

示例11: MatchHebrewDigits

        ////////////////////////////////////////////////////////////////////////
        //
        // Actions:
        //    Parse the current word as a Hebrew number.
        //      This is used by DateTime.ParseExact().
        //
        ////////////////////////////////////////////////////////////////////////

        internal static bool MatchHebrewDigits(ref __DTString str, int digitLen, out int number) {
            number = 0;

            // Create a context object so that we can parse the Hebrew number text character by character.
            HebrewNumberParsingContext context = new HebrewNumberParsingContext(0);

            // Set this to ContinueParsing so that we will run the following while loop in the first time.
            HebrewNumberParsingState state = HebrewNumberParsingState.ContinueParsing;

            while (state == HebrewNumberParsingState.ContinueParsing && str.GetNext()) {
                state = HebrewNumber.ParseByChar(str.GetChar(), ref context);
            }

            if (state == HebrewNumberParsingState.FoundEndOfHebrewNumber) {
                // If we have reached a terminal state, update the result and returns.
                number = context.result;
                return (true);
            }

            // If we run out of the character before reaching FoundEndOfHebrewNumber, or
            // the state is InvalidHebrewNumber or ContinueParsing, we fail to match a Hebrew number.
            // Return an error.
            return false;
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:32,代码来源:DateTimeParse.cs

示例12: TryParse

        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static bool TryParse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles, ref DateTimeResult result) {
            if (s == null) {
                result.SetFailure(ParseFailureKind.ArgumentNull, "ArgumentNull_String", null, "s");
                return false;
            }
            if (s.Length == 0) {
                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                return false;
            }

            Contract.Assert(dtfi != null, "dtfi == null");

#if _LOGGING
            DTFITrace(dtfi);
#endif

            DateTime time;
            //
            // First try the predefined format.
            //

            DS dps             = DS.BEGIN;     // Date Parsing State.
            bool reachTerminalState = false;

            DateTimeToken   dtok    = new DateTimeToken();      // The buffer to store the parsing token.
            dtok.suffix = TokenType.SEP_Unk;
            DateTimeRawInfo raw     = new DateTimeRawInfo();    // The buffer to store temporary parsing information.
            unsafe {
                Int32 * numberPointer = stackalloc Int32[3];
                raw.Init(numberPointer);
            }
            raw.hasSameDateAndTimeSeparators = dtfi.DateSeparator.Equals(dtfi.TimeSeparator, StringComparison.Ordinal);

            result.calendar = dtfi.Calendar;
            result.era = Calendar.CurrentEra;

            //
            // The string to be parsed. Use a __DTString wrapper so that we can trace the index which
            // indicates the begining of next token.
            //
            __DTString str = new __DTString(s, dtfi);

            str.GetNext();

            //
            // The following loop will break out when we reach the end of the str.
            //
            do {
                //
                // Call the lexer to get the next token.
                //
                // If we find a era in Lex(), the era value will be in raw.era.
                if (!Lex(dps, ref str, ref dtok, ref raw, ref result, ref dtfi, styles))
                {
                    TPTraceExit("0000", dps);
                    return false;
                }

                //
                // If the token is not unknown, process it.
                // Otherwise, just discard it.
                //
                if (dtok.dtt != DTT.Unk)
                {
                    //
                    // Check if we got any CJK Date/Time suffix.
                    // Since the Date/Time suffix tells us the number belongs to year/month/day/hour/minute/second,
                    // store the number in the appropriate field in the result.
                    //
                    if (dtok.suffix != TokenType.SEP_Unk)
                    {
                        if (!ProcessDateTimeSuffix(ref result, ref raw, ref dtok)) {
                            result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                            TPTraceExit("0010", dps);
                            return false;
                        }

                        dtok.suffix = TokenType.SEP_Unk;  // Reset suffix to SEP_Unk;
                    }

                    if (dtok.dtt == DTT.NumLocalTimeMark) {
                        if (dps == DS.D_YNd || dps == DS.D_YN) {
                            // Consider this as ISO 8601 format:
                            // "yyyy-MM-dd'T'HH:mm:ss"                 1999-10-31T02:00:00
                            TPTraceExit("0020", dps);
                            return (ParseISO8601(ref raw, ref str, styles, ref result));
                        }
                        else {
                            result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                            TPTraceExit("0030", dps);
                            return false;
                        }
                    }

                    if (raw.hasSameDateAndTimeSeparators)
                    {
                        if (dtok.dtt == DTT.YearEnd || dtok.dtt == DTT.YearSpace || dtok.dtt == DTT.YearDateSep)
                        {
                            // When time and date separators are same and we are hitting a year number while the first parsed part of the string was recognized 
//.........这里部分代码省略.........
开发者ID:ChuangYang,项目名称:coreclr,代码行数:101,代码来源:DateTimeParse.cs

示例13: VerifyValidPunctuation

 private static Boolean VerifyValidPunctuation(ref __DTString str) {
     // Compatability Behavior. Allow trailing nulls and surrounding hashes
     Char ch = str.Value[str.Index];
     if (ch == '#') {
         bool foundStart = false;
         bool foundEnd = false;
         for (int i = 0; i < str.len; i++) {
             ch = str.Value[i];
             if (ch == '#') {
                 if (foundStart) {
                     if (foundEnd) {
                         // Having more than two hashes is invalid
                         return false;
                     }
                     else {
                         foundEnd = true;
                     }
                 }
                 else {
                     foundStart = true;
                 }
             }
             else if (ch == '\0') {
                 // Allow nulls only at the end
                 if (!foundEnd) {
                     return false;
                 }
             }
             else if ((!Char.IsWhiteSpace(ch))) {
                 // Anthyhing other than whitespace outside hashes is invalid
                 if (!foundStart || foundEnd) {
                     return false;
                 }
             }
         }
         if (!foundEnd) {
             // The has was un-paired
             return false;
         }
         // Valid Hash usage: eat the hash and continue. 
         str.GetNext();  
         return true;                                                                    
     }
     else if (ch == '\0') {
         for (int i = str.Index; i < str.len; i++) {
             if (str.Value[i] != '\0') {
                 // Nulls are only valid if they are the only trailing character
                 return false;
             }
         }
         // Move to the end of the string
         str.Index = str.len;
         return true;
     }
     return false;            
 }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:56,代码来源:DateTimeParse.cs

示例14: DoStrictParse

 private static bool DoStrictParse(string s, string formatParam, DateTimeStyles styles, DateTimeFormatInfo dtfi, ref DateTimeResult result)
 {
     bool bTimeOnly = false;
     ParsingInfo parseInfo = new ParsingInfo();
     parseInfo.Init();
     parseInfo.calendar = dtfi.Calendar;
     parseInfo.fAllowInnerWhite = (styles & DateTimeStyles.AllowInnerWhite) != DateTimeStyles.None;
     parseInfo.fAllowTrailingWhite = (styles & DateTimeStyles.AllowTrailingWhite) != DateTimeStyles.None;
     if (formatParam.Length == 1)
     {
         if (((result.flags & ParseFlags.CaptureOffset) != 0) && (formatParam[0] == 'U'))
         {
             result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier", null);
             return false;
         }
         formatParam = ExpandPredefinedFormat(formatParam, ref dtfi, ref parseInfo, ref result);
     }
     result.calendar = parseInfo.calendar;
     if (parseInfo.calendar.ID == 8)
     {
         parseInfo.parseNumberDelegate = m_hebrewNumberParser;
         parseInfo.fCustomNumberParser = true;
     }
     result.Hour = result.Minute = result.Second = -1;
     __DTString format = new __DTString(formatParam, dtfi, false);
     __DTString str = new __DTString(s, dtfi, false);
     if (parseInfo.fAllowTrailingWhite)
     {
         format.TrimTail();
         format.RemoveTrailingInQuoteSpaces();
         str.TrimTail();
     }
     if ((styles & DateTimeStyles.AllowLeadingWhite) != DateTimeStyles.None)
     {
         format.SkipWhiteSpaces();
         format.RemoveLeadingInQuoteSpaces();
         str.SkipWhiteSpaces();
     }
     while (format.GetNext())
     {
         if (parseInfo.fAllowInnerWhite)
         {
             str.SkipWhiteSpaces();
         }
         if (!ParseByFormat(ref str, ref format, ref parseInfo, dtfi, ref result))
         {
             return false;
         }
     }
     if (str.Index < (str.Value.Length - 1))
     {
         result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
         return false;
     }
     if (parseInfo.fUseTwoDigitYear && ((dtfi.FormatFlags & DateTimeFormatFlags.UseHebrewRule) == DateTimeFormatFlags.None))
     {
         if (result.Year >= 100)
         {
             result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
             return false;
         }
         result.Year = parseInfo.calendar.ToFourDigitYear(result.Year);
     }
     if (parseInfo.fUseHour12)
     {
         if (parseInfo.timeMark == TM.NotSet)
         {
             parseInfo.timeMark = TM.AM;
         }
         if (result.Hour > 12)
         {
             result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
             return false;
         }
         if (parseInfo.timeMark == TM.AM)
         {
             if (result.Hour == 12)
             {
                 result.Hour = 0;
             }
         }
         else
         {
             result.Hour = (result.Hour == 12) ? 12 : (result.Hour + 12);
         }
     }
     bTimeOnly = ((result.Year == -1) && (result.Month == -1)) && (result.Day == -1);
     if (!CheckDefaultDateTime(ref result, ref parseInfo.calendar, styles))
     {
         return false;
     }
     if ((!bTimeOnly && dtfi.HasYearMonthAdjustment) && !dtfi.YearMonthAdjustment(ref result.Year, ref result.Month, (result.flags & ParseFlags.ParsedMonthName) != 0))
     {
         result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
         return false;
     }
     if (!parseInfo.calendar.TryToDateTime(result.Year, result.Month, result.Day, result.Hour, result.Minute, result.Second, 0, result.era, out result.parsedDate))
     {
         result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
         return false;
//.........这里部分代码省略.........
开发者ID:randomize,项目名称:VimConfig,代码行数:101,代码来源:DateTimeParse.cs

示例15: VerifyValidPunctuation

		private static bool VerifyValidPunctuation(ref __DTString str)
		{
			char c = str.Value[str.Index];
			if (c == '#')
			{
				bool flag = false;
				bool flag2 = false;
				for (int i = 0; i < str.len; i++)
				{
					c = str.Value[i];
					if (c == '#')
					{
						if (flag)
						{
							if (flag2)
							{
								return false;
							}
							flag2 = true;
						}
						else
						{
							flag = true;
						}
					}
					else
					{
						if (c == '\0')
						{
							if (!flag2)
							{
								return false;
							}
						}
						else
						{
							if (!char.IsWhiteSpace(c) && (!flag || flag2))
							{
								return false;
							}
						}
					}
				}
				if (!flag2)
				{
					return false;
				}
				str.GetNext();
				return true;
			}
			else
			{
				if (c == '\0')
				{
					for (int j = str.Index; j < str.len; j++)
					{
						if (str.Value[j] != '\0')
						{
							return false;
						}
					}
					str.Index = str.len;
					return true;
				}
				return false;
			}
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:67,代码来源:DateTimeParse.cs


注:本文中的System.__DTString.GetNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。