System.Globalization.CultureTableRecord.GetTimeSeparator C# (CSharp) Method

GetTimeSeparator() static private method

static private GetTimeSeparator ( String format ) : String
format String
return String
        static private String GetTimeSeparator(String format)
        {
            // Time format separator (ie: : in 12:39:00)
            //
            // We calculate this from the provided time format
            //

            //
            //  Find the time separator so that we can pretend we know STIME.
            //
            String strUse = String.Empty;
            int count = 0;
            int separatorStart = -1;

            // Look through the whole string
            for (count = 0; count < format.Length; count++)
            {
                // See if we have Hhms
                if (format[count] == 'H' || format[count] == 'h' || format[count] == 'm' || format[count] == 's')
                {
                    // Found a time part, find out when it changes
                    char cFound = format[count];

                    for (count++; count < format.Length && format[count] == cFound; count++)
                    {
                        // Done
                    }

                    // Did we find anything?
                    if (count < format.Length)
                    {
                        // We found start of separator
                        separatorStart = count;
                        break;
                    }
                }

                // If it was quotes, ignore quoted stuff
                if (format[count] == '\'')
                {
                    //
                    //  Ignore quotes.
                    //

                    for (count++; count < format.Length && (format[count] != '\''); count++)
                    {
                        // Done
                    }

                    // Don't go past end of string
                }

                // Advance to next char (skipping unknown char or last quote)
            }

            // Now we need to find the end of the separator
            if (separatorStart != -1)
            {
                for (count = separatorStart; count < format.Length; count++)
                {
                    // See if we have Hhms
                    if (format[count] == 'H' || format[count] == 'h' || format[count] == 'm' || format[count] == 's')                    {
                        // Found a time part, stop, we can look for our separator
                        // From [separatorStart, count) is our string, except we don't want ''s
                        strUse = UnescapeWin32String(format, separatorStart, count - 1);
                        break;
                    }

                    // If it was quotes, ignore quoted stuff
                    if (format[count] == '\'')
                    {
                        //
                        //  Ignore quotes.
                        //
                        for (count++; count < format.Length && (format[count] != '\''); count++)
                        {
                            // Done
                        }

                        // Don't go past end of string
                    }

                    // Advance to next char (skipping unknown char or last quote)
                }
            }

            // Return the one we're using
            return strUse;
        }