The result of the following snippet is \"12/06/1930 12:00:00\". How do I control the implied century so that \"12 Jun 30\" becomes 2030 instead?
string
I had a similar problem and I solved it with a Regex. In your case it would look like that:
private static readonly Regex DateRegex = new Regex(
@"^[0-9][0-9] (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9][0-9]$",
RegexOptions.Compiled | RegexOptions.ExplicitCapture);
private static string Beautify(string date)
{
var match = DateRegex.Match(date);
if (match.Success)
{
// Maybe further checks for correct day
return date.Insert("dd-MMM-".Length, "20");
}
return date;
}