Subtext.Framework.Format.UrlFormats.DateFromUrl C# (CSharp) Method

DateFromUrl() public static method

Returns a DateTime instance parsed from the url.
public static DateFromUrl ( string url ) : System.DateTime
url string URL.
return System.DateTime
        public static DateTime DateFromUrl(string url)
        {
            string date = GetRequestedFileName(url);
            CultureInfo en = new CultureInfo("en-US");
            switch(date.Length)
            {
                case 8:
                    return DateTime.ParseExact(date,"MMddyyyy", en);
                case 6:
                    return DateTime.ParseExact(date,"MMyyyy", en);
                default:
                    throw new Exception("Invalid Date Format");
            }
        }