private static bool TryReadOffset(StringReference offsetText, int startIndex, out TimeSpan offset) { bool negative = (offsetText[startIndex] == '-'); if (ConvertUtils.Int32TryParse(offsetText.Chars, startIndex + 1, 2, out int hours) != ParseResult.Success) { offset = default; return(false); } int minutes = 0; if (offsetText.Length - startIndex > 5) { if (ConvertUtils.Int32TryParse(offsetText.Chars, startIndex + 3, 2, out minutes) != ParseResult.Success) { offset = default; return(false); } } offset = TimeSpan.FromHours(hours) + TimeSpan.FromMinutes(minutes); if (negative) { offset = offset.Negate(); } return(true); }
private static bool TryReadOffset( StringReference offsetText, int startIndex, out TimeSpan offset) { bool flag = offsetText[startIndex] == '-'; int num1; if (ConvertUtils.Int32TryParse(offsetText.Chars, startIndex + 1, 2, out num1) != ParseResult.Success) { offset = new TimeSpan(); return(false); } int num2 = 0; if (offsetText.Length - startIndex > 5 && ConvertUtils.Int32TryParse(offsetText.Chars, startIndex + 3, 2, out num2) != ParseResult.Success) { offset = new TimeSpan(); return(false); } offset = TimeSpan.FromHours((double)num1) + TimeSpan.FromMinutes((double)num2); if (flag) { offset = offset.Negate(); } return(true); }