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

GetDateSeparator() static private method

static private GetDateSeparator ( String format ) : String
format String
return String
        static private String GetDateSeparator(String format)
        {
            // Date format separator (ie: / in 9/1/03)
            //
            // We calculate this from the provided short date
            //

            //
            //  Find the date separator so that we can pretend we know SDATE.
            //
            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 dyM
                if (format[count] == 'd' || format[count] == 'y' || format[count] == 'M')
                {
                    // 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 yMd
                    if (format[count] == 'y' || format[count] == 'M' || format[count] == 'd')
                    {
                        // 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;
        }