I need to search for, and parse, a datetime (formatted based on current culture) in a string.
The best I can come up with at the moment is:
string text = String.Format("Time is {0}; all's well", DateTime.Now);
DateTime date = new DateTime();
for (int start = 0; start < text.Length - 1; start++)
for (int length = text.Length - start; length > 0; length--)
if (DateTime.TryParse(text.Substring(start, length), out date))
return date;
Is there a smarter way to do this?