// // ProcessTerminal_HMS_F_D // // Actions: Validate the ambiguous 4-number "Hours:Minutes:Seconds.Fraction", "Days.Hours:Minutes:Seconds", or "Days.Hours:Minutes:.Fraction" terminal case. // Sets result.parsedTimeSpan on success. // private static Boolean ProcessTerminal_HMS_F_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result) { if (raw.SepCount != 5 || raw.NumCount != 4 || (style & TimeSpanStandardStyles.RequireFull) != 0) { result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; } bool inv = ((style & TimeSpanStandardStyles.Invariant) != 0); bool loc = ((style & TimeSpanStandardStyles.Localized) != 0); long ticks = 0; bool positive = false; bool match = false; bool overflow = false; if (inv) { if (raw.FullHMSFMatch(raw.PositiveInvariant)) { positive = true; match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out ticks); overflow = overflow || !match; } if (!match && raw.FullDHMSMatch(raw.PositiveInvariant)) { positive = true; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out ticks); overflow = overflow || !match; } if (!match && raw.FullAppCompatMatch(raw.PositiveInvariant)) { positive = true; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out ticks); overflow = overflow || !match; } if (!match && raw.FullHMSFMatch(raw.NegativeInvariant)) { positive = false; match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out ticks); overflow = overflow || !match; } if (!match && raw.FullDHMSMatch(raw.NegativeInvariant)) { positive = false; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out ticks); overflow = overflow || !match; } if (!match && raw.FullAppCompatMatch(raw.NegativeInvariant)) { positive = false; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out ticks); overflow = overflow || !match; } } if (loc) { if (!match && raw.FullHMSFMatch(raw.PositiveLocalized)) { positive = true; match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out ticks); overflow = overflow || !match; } if (!match && raw.FullDHMSMatch(raw.PositiveLocalized)) { positive = true; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out ticks); overflow = overflow || !match; } if (!match && raw.FullAppCompatMatch(raw.PositiveLocalized)) { positive = true; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out ticks); overflow = overflow || !match; } if (!match && raw.FullHMSFMatch(raw.NegativeLocalized)) { positive = false; match = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out ticks); overflow = overflow || !match; } if (!match && raw.FullDHMSMatch(raw.NegativeLocalized)) { positive = false; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out ticks); overflow = overflow || !match; } if (!match && raw.FullAppCompatMatch(raw.NegativeLocalized)) { positive = false; match = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out ticks); overflow = overflow || !match; } } if (match) { if (!positive) { ticks = -ticks; if (ticks > 0) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } } result.parsedTimeSpan._ticks = ticks; return true; } if (overflow) { // we found at least one literal pattern match but the numbers just didn't fit result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } else { // we couldn't find a thing result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; } }
private static bool ProcessTerminal_HMS_F_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result) { if (((raw.SepCount != 5) || (raw.NumCount != 4)) || ((style & TimeSpanStandardStyles.RequireFull) != TimeSpanStandardStyles.None)) { result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; } bool flag = (style & TimeSpanStandardStyles.Invariant) != TimeSpanStandardStyles.None; bool flag2 = (style & TimeSpanStandardStyles.Localized) != TimeSpanStandardStyles.None; long num = 0L; bool positive = false; bool flag4 = false; bool flag5 = false; if (flag) { if (raw.FullHMSFMatch(raw.PositiveInvariant)) { positive = true; flag4 = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullDHMSMatch(raw.PositiveInvariant)) { positive = true; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullAppCompatMatch(raw.PositiveInvariant)) { positive = true; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullHMSFMatch(raw.NegativeInvariant)) { positive = false; flag4 = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullDHMSMatch(raw.NegativeInvariant)) { positive = false; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullAppCompatMatch(raw.NegativeInvariant)) { positive = false; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out num); flag5 = flag5 || !flag4; } } if (flag2) { if (!flag4 && raw.FullHMSFMatch(raw.PositiveLocalized)) { positive = true; flag4 = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullDHMSMatch(raw.PositiveLocalized)) { positive = true; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullAppCompatMatch(raw.PositiveLocalized)) { positive = true; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullHMSFMatch(raw.NegativeLocalized)) { positive = false; flag4 = TryTimeToTicks(positive, zero, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullDHMSMatch(raw.NegativeLocalized)) { positive = false; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], raw.numbers[3], zero, out num); flag5 = flag5 || !flag4; } if (!flag4 && raw.FullAppCompatMatch(raw.NegativeLocalized)) { positive = false; flag4 = TryTimeToTicks(positive, raw.numbers[0], raw.numbers[1], raw.numbers[2], zero, raw.numbers[3], out num); flag5 = flag5 || !flag4; } } if (flag4) { if (!positive) { num = -num; if (num > 0L) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } } result.parsedTimeSpan._ticks = num; return true; } if (flag5) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; }