// // ProcessTerminal_D // // Actions: Validate the 1-number "Days" terminal case // private static Boolean ProcessTerminal_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result) { if (raw.SepCount != 2 || raw.NumCount != 1 || (style & TimeSpanStandardStyles.RequireFull) != 0) { result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; } bool inv = ((style & TimeSpanStandardStyles.Invariant) != 0); bool loc = ((style & TimeSpanStandardStyles.Localized) != 0); bool positive = false; bool match = false; if (inv) { if (raw.FullDMatch(raw.PositiveInvariant)) { match = true; positive = true; } if (!match && raw.FullDMatch(raw.NegativeInvariant)) { match = true; positive = false; } } if (loc) { if (!match && raw.FullDMatch(raw.PositiveLocalized)) { match = true; positive = true; } if (!match && raw.FullDMatch(raw.NegativeLocalized)) { match = true; positive = false; } } long ticks = 0; if (match) { if (!TryTimeToTicks(positive, raw.numbers[0], zero, zero, zero, zero, out ticks)) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } if (!positive) { ticks = -ticks; if (ticks > 0) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } } result.parsedTimeSpan._ticks = ticks; return true; } result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; }
private static bool ProcessTerminal_D(ref TimeSpanRawInfo raw, TimeSpanStandardStyles style, ref TimeSpanResult result) { if (((raw.SepCount != 2) || (raw.NumCount != 1)) || ((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; bool positive = false; bool flag4 = false; if (flag) { if (raw.FullDMatch(raw.PositiveInvariant)) { flag4 = true; positive = true; } if (!flag4 && raw.FullDMatch(raw.NegativeInvariant)) { flag4 = true; positive = false; } } if (flag2) { if (!flag4 && raw.FullDMatch(raw.PositiveLocalized)) { flag4 = true; positive = true; } if (!flag4 && raw.FullDMatch(raw.NegativeLocalized)) { flag4 = true; positive = false; } } long num = 0L; if (flag4) { if (!TryTimeToTicks(positive, raw.numbers[0], zero, zero, zero, zero, out num)) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } if (!positive) { num = -num; if (num > 0L) { result.SetFailure(ParseFailureKind.Overflow, "Overflow_TimeSpanElementTooLarge"); return false; } } result.parsedTimeSpan._ticks = num; return true; } result.SetFailure(ParseFailureKind.Format, "Format_BadTimeSpan"); return false; }