System.DateTimeParse.GetDayOfMN C# (CSharp) Method

GetDayOfMN() private static method

private static GetDayOfMN ( DateTimeResult &result, DateTimeRawInfo &raw, DateTimeFormatInfo dtfi ) : Boolean
result DateTimeResult
raw DateTimeRawInfo
dtfi DateTimeFormatInfo
return Boolean
        private static Boolean GetDayOfMN(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         Day
            //    dd MMMM           MMMM yyyy         Year
            //    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_DM) {
                int yearMonthOrder;
                if (!GetYearMonthOrder(dtfi.YearMonthPattern, dtfi, out yearMonthOrder)) {
                    result.SetFailure(ParseFailureKind.FormatWithParameter, "Format_BadDatePattern", dtfi.YearMonthPattern);
                    return false;
                }
                if (yearMonthOrder == ORDER_MY) {
                    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;

        }