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


C# __DTString.Match方法代码示例

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


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

示例1: ParseTimeZoneOffset

		private static bool ParseTimeZoneOffset(ref __DTString str, int len, ref TimeSpan result)
		{
			bool flag = true;
			int num = 0;
			int hours;
			switch (len)
			{
				case 1:
				case 2:
				{
					if (!DateTimeParse.ParseSign(ref str, ref flag))
					{
						return false;
					}
					if (!DateTimeParse.ParseDigits(ref str, len, out hours))
					{
						return false;
					}
					break;
				}
				default:
				{
					if (!DateTimeParse.ParseSign(ref str, ref flag))
					{
						return false;
					}
					if (!DateTimeParse.ParseDigits(ref str, 1, out hours))
					{
						return false;
					}
					if (str.Match(":"))
					{
						if (!DateTimeParse.ParseDigits(ref str, 2, out num))
						{
							return false;
						}
					}
					else
					{
						str.Index--;
						if (!DateTimeParse.ParseDigits(ref str, 2, out num))
						{
							return false;
						}
					}
					break;
				}
			}
			if (num < 0 || num >= 60)
			{
				return false;
			}
			result = new TimeSpan(hours, num, 0);
			if (!flag)
			{
				result = result.Negate();
			}
			return true;
		}
开发者ID:ChristianWulf,项目名称:CSharpKDMDiscoverer,代码行数:59,代码来源: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: ParseByFormat

        // Given a specified format character, parse and update the parsing result.
        //
        private static bool ParseByFormat(
            ref __DTString str,
            ref __DTString format,
            ref ParsingInfo parseInfo,
            DateTimeFormatInfo dtfi,
            ref DateTimeResult result) {

            int tokenLen = 0;
            int tempYear = 0, tempMonth = 0, tempDay = 0, tempDayOfWeek = 0, tempHour = 0, tempMinute = 0, tempSecond = 0;
            double tempFraction = 0;
            TM tempTimeMark = 0;

            char ch = format.GetChar();

            switch (ch) {
                case 'y':
                    tokenLen = format.GetRepeatCount();
                    bool parseResult;
                    if (dtfi.HasForceTwoDigitYears) {
                        parseResult = ParseDigits(ref str, 1, 4, out tempYear);
                    }
                    else {
                        if (tokenLen <= 2) {
                            parseInfo.fUseTwoDigitYear = true;
                        }
                        parseResult = ParseDigits(ref str, tokenLen, out tempYear);
                    }
                    if (!parseResult && parseInfo.fCustomNumberParser) {
                        parseResult = parseInfo.parseNumberDelegate(ref str, tokenLen, out tempYear);
                    }
                    if (!parseResult) {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return (false);
                    }
                    if (!CheckNewValue(ref result.Year, tempYear, ch, ref result)) {
                        return (false);
                    }
                    break;
                case 'M':
                    tokenLen = format.GetRepeatCount();
                    if (tokenLen <= 2) {
                        if (!ParseDigits(ref str, tokenLen, out tempMonth)) {
                            if (!parseInfo.fCustomNumberParser ||
                                !parseInfo.parseNumberDelegate(ref str, tokenLen, out tempMonth)) {
                                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                                return (false);
                            }
                        }
                    } else {
                        if (tokenLen == 3) {
                            if (!MatchAbbreviatedMonthName(ref str, dtfi, ref tempMonth)) {
                                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                                return (false);
                            }
                        } else {
                            if (!MatchMonthName(ref str, dtfi, ref tempMonth)) {
                                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                                return (false);
                            }
                        }
                        result.flags |= ParseFlags.ParsedMonthName;
                    }
                    if (!CheckNewValue(ref result.Month, tempMonth, ch, ref result)) {
                        return (false);
                    }
                    break;
                case 'd':
                    // Day & Day of week
                    tokenLen = format.GetRepeatCount();
                    if (tokenLen <= 2) {
                        // "d" & "dd"

                        if (!ParseDigits(ref str, tokenLen, out tempDay)) {
                            if (!parseInfo.fCustomNumberParser ||
                                !parseInfo.parseNumberDelegate(ref str, tokenLen, out tempDay)) {
                                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                                return (false);
                            }
                        }
                        if (!CheckNewValue(ref result.Day, tempDay, ch, ref result)) {
                            return (false);
                        }
                    } else {
                        if (tokenLen == 3) {
                            // "ddd"
                            if (!MatchAbbreviatedDayName(ref str, dtfi, ref tempDayOfWeek)) {
                                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                                return (false);
                            }
                        } else {
                            // "dddd*"
                            if (!MatchDayName(ref str, dtfi, ref tempDayOfWeek)) {
                                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                                return (false);
                            }
                        }
                        if (!CheckNewValue(ref parseInfo.dayOfWeek, tempDayOfWeek, ch, ref result)) {
                            return (false);
//.........这里部分代码省略.........
开发者ID:ChuangYang,项目名称:coreclr,代码行数:101,代码来源:DateTimeParse.cs

示例4: 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

示例5: 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

示例6: ParseTimeZoneOffset

        /*=================================ParseTimeZoneOffset==================================
        **Action: Parse the string formatted using "z", "zz", "zzz" in DateTime.Format().
        **Returns: the TimeSpan for the parsed timezone offset.
        **Arguments:    str: a __DTString.  The parsing will start from the
        **              next character after str.Index.
        **              len: the repeated number of the "z"
        **Exceptions: FormatException if errors in parsing.
        ==============================================================================*/

        private static bool ParseTimeZoneOffset(ref __DTString str, int len, ref TimeSpan result) {
            bool isPositive = true;
            int hourOffset;
            int minuteOffset = 0;

            switch (len) {
                case 1:
                case 2:
                    if (!ParseSign(ref str, ref isPositive)) {
                        return (false);
                    }
                    if (!ParseDigits(ref str, len, out hourOffset)) {
                        return (false);
                    }
                    break;
                default:
                    if (!ParseSign(ref str, ref isPositive)) {
                        return (false);
                    }

                    // Parsing 1 digit will actually parse 1 or 2.
                    if (!ParseDigits(ref str, 1, out hourOffset)) {
                        return (false);
                    }
                    // ':' is optional.
                    if (str.Match(":")) {
                        // Found ':'
                        if (!ParseDigits(ref str, 2, out minuteOffset)) {
                            return (false);
                        }
                    } else {
                        // Since we can not match ':', put the char back.
                        str.Index--;
                        if (!ParseDigits(ref str, 2, out minuteOffset)) {
                            return (false);
                        }
                    }
                    break;
            }
            if (minuteOffset < 0 || minuteOffset >= 60) {
                return false;
            }

            result = (new TimeSpan(hourOffset, minuteOffset, 0));
            if (!isPositive) {
                result = result.Negate();
            }
            return (true);
        }
开发者ID:ChuangYang,项目名称:coreclr,代码行数:58,代码来源:DateTimeParse.cs

示例7: ParseTimeZoneOffset

        private static bool ParseTimeZoneOffset(ref __DTString str, int len, ref TimeSpan result)
        {
            int num;
            bool flag = true;
            int num2 = 0;
            switch (len)
            {
                case 1:
                case 2:
                    if (ParseSign(ref str, ref flag))
                    {
                        if (ParseDigits(ref str, len, out num))
                        {
                            break;
                        }
                        return false;
                    }
                    return false;

                default:
                    if (!ParseSign(ref str, ref flag))
                    {
                        return false;
                    }
                    if (!ParseDigits(ref str, 1, out num))
                    {
                        return false;
                    }
                    if (str.Match(":"))
                    {
                        if (!ParseDigits(ref str, 2, out num2))
                        {
                            return false;
                        }
                    }
                    else
                    {
                        str.Index--;
                        if (!ParseDigits(ref str, 2, out num2))
                        {
                            return false;
                        }
                    }
                    break;
            }
            if ((num2 < 0) || (num2 >= 60))
            {
                return false;
            }
            result = new TimeSpan(num, num2, 0);
            if (!flag)
            {
                result = result.Negate();
            }
            return true;
        }
开发者ID:randomize,项目名称:VimConfig,代码行数:56,代码来源:DateTimeParse.cs

示例8: ParseISO8601

        private static bool ParseISO8601(ref DateTimeRawInfo raw, ref __DTString str, DateTimeStyles styles, ref DateTimeResult result)
        {
            int num;
            int num2;
            DateTime time;
            if ((raw.year >= 0) && (raw.GetNumber(0) >= 0))
            {
                raw.GetNumber(1);
            }
            str.Index--;
            int num3 = 0;
            double num4 = 0.0;
            str.SkipWhiteSpaces();
            if (!ParseDigits(ref str, 2, out num))
            {
                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 num2))
            {
                result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                return false;
            }
            str.SkipWhiteSpaces();
            if (str.Match(':'))
            {
                str.SkipWhiteSpaces();
                if (!ParseDigits(ref str, 2, out num3))
                {
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;
                }
                if (str.Match('.'))
                {
                    if (!ParseFraction(ref str, out num4))
                    {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return false;
                    }
                    str.Index--;
                }
                str.SkipWhiteSpaces();
            }
            if (str.GetNext())
            {
                switch (str.GetChar())
                {
                    case '+':
                    case '-':
                        result.flags |= ParseFlags.TimeZoneUsed;
                        if (!ParseTimeZone(ref str, ref result.timeZoneOffset))
                        {
                            result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                            return false;
                        }
                        break;

                    case 'Z':
                    case 'z':
                        result.flags |= ParseFlags.TimeZoneUsed;
                        result.timeZoneOffset = TimeSpan.Zero;
                        result.flags |= ParseFlags.TimeZoneUtc;
                        break;

                    default:
                        str.Index--;
                        break;
                }
                str.SkipWhiteSpaces();
                if (str.Match('#'))
                {
                    if (!VerifyValidPunctuation(ref str))
                    {
                        result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                        return false;
                    }
                    str.SkipWhiteSpaces();
                }
                if (str.Match('\0') && !VerifyValidPunctuation(ref str))
                {
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;
                }
                if (str.GetNext())
                {
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;
                }
            }
            if (!GregorianCalendar.GetDefaultInstance().TryToDateTime(raw.year, raw.GetNumber(0), raw.GetNumber(1), num, num2, num3, 0, result.era, out time))
            {
                result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
                return false;
//.........这里部分代码省略.........
开发者ID:randomize,项目名称:VimConfig,代码行数:101,代码来源:DateTimeParse.cs

示例9: ParseByFormat

        private static bool ParseByFormat(ref __DTString str, ref __DTString format, ref ParsingInfo parseInfo, DateTimeFormatInfo dtfi, ref DateTimeResult result)
        {
            bool flag;
            int returnValue = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;
            int num6 = 0;
            int num7 = 0;
            int num8 = 0;
            double num9 = 0.0;
            TM aM = TM.AM;
            char failureMessageFormatArgument = format.GetChar();
            switch (failureMessageFormatArgument)
            {
                case '%':
                    if ((format.Index < (format.Value.Length - 1)) && (format.Value[format.Index + 1] != '%'))
                    {
                        goto Label_0A5A;
                    }
                    result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier", null);
                    return false;

                case '\'':
                case '"':
                {
                    StringBuilder builder = new StringBuilder();
                    if (!TryParseQuoteString(format.Value, format.Index, builder, out returnValue))
                    {
                        result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadQuote", failureMessageFormatArgument);
                        return false;
                    }
                    format.Index += returnValue - 1;
                    string str2 = builder.ToString();
                    for (int i = 0; i < str2.Length; i++)
                    {
                        if ((str2[i] == ' ') && parseInfo.fAllowInnerWhite)
                        {
                            str.SkipWhiteSpaces();
                        }
                        else if (!str.Match(str2[i]))
                        {
                            result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                            return false;
                        }
                    }
                    if ((result.flags & ParseFlags.CaptureOffset) != 0)
                    {
                        if (((result.flags & ParseFlags.Rfc1123Pattern) != 0) && (str2 == "GMT"))
                        {
                            result.flags |= ParseFlags.TimeZoneUsed;
                            result.timeZoneOffset = TimeSpan.Zero;
                        }
                        else if (((result.flags & ParseFlags.UtcSortPattern) != 0) && (str2 == "Z"))
                        {
                            result.flags |= ParseFlags.TimeZoneUsed;
                            result.timeZoneOffset = TimeSpan.Zero;
                        }
                    }
                    goto Label_0A5A;
                }
                case '.':
                    if (!str.Match(failureMessageFormatArgument))
                    {
                        if (!format.GetNext() || !format.Match('F'))
                        {
                            result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                            return false;
                        }
                        format.GetRepeatCount();
                    }
                    goto Label_0A5A;

                case '/':
                    if (str.Match(dtfi.DateSeparator))
                    {
                        goto Label_0A5A;
                    }
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;

                case ':':
                    if (str.Match(dtfi.TimeSeparator))
                    {
                        goto Label_0A5A;
                    }
                    result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                    return false;

                case 'F':
                case 'f':
                    returnValue = format.GetRepeatCount();
                    if (returnValue <= 7)
                    {
                        if (!ParseFractionExact(ref str, returnValue, ref num9) && (failureMessageFormatArgument == 'f'))
                        {
                            result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
                            return false;
                        }
//.........这里部分代码省略.........
开发者ID:randomize,项目名称:VimConfig,代码行数:101,代码来源:DateTimeParse.cs

示例10: ParseByFormat

        // Given a specified format character, parse and update the parsing result.
        //
        private static bool ParseByFormat(
            __DTString str, 
            __DTString format, 
            ParsingInfo parseInfo, 
            DateTimeFormatInfo dtfi,
            bool isThrowExp,
            DateTimeResult result) {
            
            int tokenLen = 0;
            int tempYear = 0, tempMonth = 0, tempDay = 0, tempDayOfWeek = 0, tempHour = 0, tempMinute = 0, tempSecond = 0;
            double tempFraction = 0;
            int tempTimeMark = 0;
            
            char ch = format.GetChar();
            
            switch (ch) {
                case 'y':
                    tokenLen = format.GetRepeatCount();
                    if (tokenLen <= 2) {
                        parseInfo.fUseTwoDigitYear = true;
                    }
                    if (!ParseDigits(str, tokenLen, isThrowExp, out tempYear)) {
                        return (false);
                    }                    
                    if (!CheckNewValue(ref result.Year, tempYear, ch, isThrowExp)) {
                        return (false);
                    }
                    break;
                case 'M':
                    tokenLen = format.GetRepeatCount();
                    if (tokenLen <= 2) {
                        if (!ParseDigits(str, tokenLen, isThrowExp, out tempMonth)) {
                            return (false);
                        }
                    } else {
                        if (tokenLen == 3) {
                            if (!MatchAbbreviatedMonthName(str, dtfi, isThrowExp, ref tempMonth)) {
                                return (false);
                            }
                        } else {
                            if (!MatchMonthName(str, dtfi, isThrowExp, ref tempMonth)) {
                                return (false);
                            }
                        }
                    }
                    if (!CheckNewValue(ref result.Month, tempMonth, ch, isThrowExp)) {
                        return (false);
                    }
                    break;
                case 'd':
                    // Day & Day of week
                    tokenLen = format.GetRepeatCount();
                    if (tokenLen <= 2) {
                        // "d" & "dd"
                        if (!ParseDigits(str, tokenLen, isThrowExp, out tempDay)) {
                            return (false);
                        }
                        if (!CheckNewValue(ref result.Day, tempDay, ch, isThrowExp)) {
                            return (false);
                        }
                    } else {
                        if (tokenLen == 3) {
                            // "ddd"
                            if (!MatchAbbreviatedDayName(str, dtfi, isThrowExp, ref tempDayOfWeek)) {
                                return (false);
                            }
                        } else {
                            // "dddd*"
                            if (!MatchDayName(str, dtfi, isThrowExp, ref tempDayOfWeek)) {
                                return (false);
                            }
                        }
                        if (!CheckNewValue(ref parseInfo.dayOfWeek, tempDayOfWeek, ch, isThrowExp)) {
                            return (false);
                        }
                    }
                    break;
                case 'g':
                    tokenLen = format.GetRepeatCount();
                    // Put the era value in result.era.
                    if (!MatchEraName(str, dtfi, isThrowExp, ref result.era)) {
                        return (false);
                    }
                    break;
                case 'h':
                    parseInfo.fUseHour12 = true;
                    tokenLen = format.GetRepeatCount();
                    if (!ParseDigits(str, (tokenLen < 2? 1 : 2), isThrowExp, out tempHour)) {
                        return (false);
                    }
                    if (!CheckNewValue(ref result.Hour, tempHour, ch, isThrowExp)) {
                        return (false);
                    }
                    break;
                case 'H':
                    tokenLen = format.GetRepeatCount();
                    if (!ParseDigits(str, (tokenLen < 2? 1 : 2), isThrowExp, out tempHour)) {
                        return (false);
//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:datetimeparse.cs

示例11: ParseISO8601

 //
 // Parse the ISO8601 format string found during Parse();
 // 
 //
 private static DateTime ParseISO8601(DateTimeRawInfo raw, __DTString str, DateTimeStyles styles) {
     if (raw.year < 0 || raw.num[0] < 0 || raw.num[1] < 0) {
     }
     str.Index--;
     int hour, minute, second;
     bool timeZoneUsed = false;
     TimeSpan timeZoneOffset = new TimeSpan();
     DateTime time = new DateTime(0);
     double partSecond = 0;
     
     str.SkipWhiteSpaces();            
     ParseDigits(str, 2, true, out hour);
     str.SkipWhiteSpaces();
     if (str.Match(':')) {
         str.SkipWhiteSpaces();
         ParseDigits(str, 2, true, out minute);    
         str.SkipWhiteSpaces();
         if (str.Match(':')) {
             str.SkipWhiteSpaces();
             ParseDigits(str, 2, true, out second);    
             str.SkipWhiteSpaces();
             
             if (str.GetNext()) {
                 char ch = str.GetChar();
                 if (ch == '+' || ch == '-') {
                     timeZoneUsed = true;
                     timeZoneOffset = ParseTimeZone(str, str.GetChar());
                 } else if (ch == '.') {
                     str.Index++;  //ParseFraction requires us to advance to the next character.
                     partSecond = ParseFraction(str); 
                 } else if (ch == 'Z' || ch == 'z') {
                     timeZoneUsed = true;
                 } else {
                     throw new FormatException(Environment.GetResourceString("Format_BadDateTime"));            
                 }
             }
             
             time =new DateTime(raw.year, raw.num[0], raw.num[1], hour, minute, second);
             time = time.AddTicks((long)Math.Round(partSecond * Calendar.TicksPerSecond));
             if (timeZoneUsed) {
                 time = AdjustTimeZone(time, timeZoneOffset, styles, false);
             }
             
             return time;
         }
     }
     throw new FormatException(Environment.GetResourceString("Format_BadDateTime"));            
 }
开发者ID:ArildF,项目名称:masters,代码行数:52,代码来源:datetimeparse.cs


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