private static bool DoStrictParse(string s, string formatParam, DateTimeStyles styles, DateTimeFormatInfo dtfi, ref DateTimeResult result)
{
ParsingInfo parsingInfo = default(ParsingInfo);
parsingInfo.Init();
parsingInfo.calendar = dtfi.Calendar;
parsingInfo.fAllowInnerWhite = ((styles & DateTimeStyles.AllowInnerWhite) != DateTimeStyles.None);
parsingInfo.fAllowTrailingWhite = ((styles & DateTimeStyles.AllowTrailingWhite) != DateTimeStyles.None);
if (formatParam.Length == 1)
{
if ((result.flags & ParseFlags.CaptureOffset) != (ParseFlags)0 && formatParam[0] == 'U')
{
result.SetFailure(ParseFailureKind.Format, "Format_BadFormatSpecifier", null);
return false;
}
formatParam = DateTimeParse.ExpandPredefinedFormat(formatParam, ref dtfi, ref parsingInfo, ref result);
}
result.calendar = parsingInfo.calendar;
if (parsingInfo.calendar.ID == 8)
{
parsingInfo.parseNumberDelegate = DateTimeParse.m_hebrewNumberParser;
parsingInfo.fCustomNumberParser = true;
}
result.Hour = (result.Minute = (result.Second = -1));
__DTString _DTString = new __DTString(formatParam, dtfi, false);
__DTString _DTString2 = new __DTString(s, dtfi, false);
if (parsingInfo.fAllowTrailingWhite)
{
_DTString.TrimTail();
_DTString.RemoveTrailingInQuoteSpaces();
_DTString2.TrimTail();
}
if ((styles & DateTimeStyles.AllowLeadingWhite) != DateTimeStyles.None)
{
_DTString.SkipWhiteSpaces();
_DTString.RemoveLeadingInQuoteSpaces();
_DTString2.SkipWhiteSpaces();
}
while (_DTString.GetNext())
{
if (parsingInfo.fAllowInnerWhite)
{
_DTString2.SkipWhiteSpaces();
}
if (!DateTimeParse.ParseByFormat(ref _DTString2, ref _DTString, ref parsingInfo, dtfi, ref result))
{
return false;
}
}
if (_DTString2.Index < _DTString2.Value.Length - 1)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
if (parsingInfo.fUseTwoDigitYear && (dtfi.FormatFlags & DateTimeFormatFlags.UseHebrewRule) == DateTimeFormatFlags.None)
{
if (result.Year >= 100)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
result.Year = parsingInfo.calendar.ToFourDigitYear(result.Year);
}
if (parsingInfo.fUseHour12)
{
if (parsingInfo.timeMark == DateTimeParse.TM.NotSet)
{
parsingInfo.timeMark = DateTimeParse.TM.AM;
}
if (result.Hour > 12)
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
if (parsingInfo.timeMark == DateTimeParse.TM.AM)
{
if (result.Hour == 12)
{
result.Hour = 0;
}
}
else
{
result.Hour = ((result.Hour == 12) ? 12 : (result.Hour + 12));
}
}
else
{
if ((parsingInfo.timeMark == DateTimeParse.TM.AM && result.Hour >= 12) || (parsingInfo.timeMark == DateTimeParse.TM.PM && result.Hour < 12))
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
}
bool flag = result.Year == -1 && result.Month == -1 && result.Day == -1;
if (!DateTimeParse.CheckDefaultDateTime(ref result, ref parsingInfo.calendar, styles))
{
return false;
}
if (!flag && dtfi.HasYearMonthAdjustment && !dtfi.YearMonthAdjustment(ref result.Year, ref result.Month, (result.flags & ParseFlags.ParsedMonthName) != (ParseFlags)0))
{
result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, "Format_BadDateTimeCalendar", null);
return false;
}
if (!parsingInfo.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;
}
if (result.fraction > 0.0)
{
result.parsedDate = result.parsedDate.AddTicks((long)Math.Round(result.fraction * 10000000.0));
}
if (parsingInfo.dayOfWeek != -1 && parsingInfo.dayOfWeek != (int)parsingInfo.calendar.GetDayOfWeek(result.parsedDate))
{
result.SetFailure(ParseFailureKind.Format, "Format_BadDayOfWeek", null);
return false;
}
return DateTimeParse.DetermineTimeZoneAdjustments(ref result, styles, flag);
}