private static Boolean GetDayOfNM(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi)
{
if ((result.flags & ParseFlags.HaveDate) != 0) {
// Multiple dates in the input string
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
// The interpretation is based on the MonthDayPattern and YearMonthPattern
//
// MonthDayPattern YearMonthPattern Interpretation
// --------------- ---------------- ---------------
// MMMM dd MMMM yyyy Day
// MMMM dd yyyy MMMM Year
// dd MMMM MMMM yyyy Day
// dd MMMM yyyy MMMM Day
//
// In the first and last cases, it could be either or neither, but a day is a better default interpretation
// than a 2 digit year.
int monthDayOrder;
if (!GetMonthDayOrder(dtfi.MonthDayPattern, dtfi, out monthDayOrder)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.MonthDayPattern);
return false;
}
if (monthDayOrder == ORDER_MD) {
int yearMonthOrder;
if (!GetYearMonthOrder(dtfi.YearMonthPattern, dtfi, out yearMonthOrder)) {
result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.YearMonthPattern);
return false;
}
if (yearMonthOrder == ORDER_YM) {
if (!SetDateYMD(ref result, AdjustYear(ref result, raw.GetNumber(0)), raw.month, 1)) {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
return true;
}
}
int currentYear = result.calendar.GetYear(DateTime.Now);
if (!SetDateYMD(ref result, currentYear, raw.month, raw.GetNumber(0))) {
result.SetFailure(ParseFailureKind.Format, "Format_BadDateTime", null);
return false;
}
return true;
}