System.DateTimeParse.MatchTimeMark C# (CSharp) Method

MatchTimeMark() private static method

private static MatchTimeMark ( __DTString &str, DateTimeFormatInfo dtfi, TM &result ) : bool
str __DTString
dtfi DateTimeFormatInfo
result TM
return bool
        private static bool MatchTimeMark(ref __DTString str, DateTimeFormatInfo dtfi, ref TM result) {
            result = TM.NotSet;
            // In some cultures have empty strings in AM/PM mark. E.g. af-ZA (0x0436), the AM mark is "", and PM mark is "nm".
            if (dtfi.AMDesignator.Length == 0) {
                result = TM.AM;
            }
            if (dtfi.PMDesignator.Length == 0) {
                result = TM.PM;
            }

            if (str.GetNext()) {
                String searchStr = dtfi.AMDesignator;
                if (searchStr.Length > 0) {
                    if (str.MatchSpecifiedWord(searchStr)) {
                        // Found an AM timemark with length > 0.
                        str.Index += (searchStr.Length - 1);
                        result = TM.AM;
                        return (true);
                    }
                }
                searchStr = dtfi.PMDesignator;
                if (searchStr.Length > 0) {
                    if (str.MatchSpecifiedWord(searchStr)) {
                        // Found a PM timemark with length > 0.
                        str.Index += (searchStr.Length - 1);
                        result = TM.PM;
                        return (true);
                    }
                }
                str.Index--; // Undo the GetNext call.
            }
            if (result != TM.NotSet) {
                // If one of the AM/PM marks is empty string, return the result.
                return (true);
            }
            return false;
        }