public static string FormatToBDA(string dateandage)
{
Parsers p = new Parsers();
string original = dateandage;
// clean up date format if possible
dateandage = p.FixDateOrdinalsAndOf(" " + dateandage, "test");
// remove date wikilinks
dateandage = WikiRegexes.WikiLinksOnlyPossiblePipe.Replace(dateandage, "$1").Trim();
// string must end with (age xx)
if (!AgeBrackets.IsMatch(dateandage))
return original;
dateandage = AgeBrackets.Replace(dateandage, "");
string ISODate = Tools.ConvertDate(dateandage, DateLocale.ISO);
if (ISODate.Equals(dateandage) && !WikiRegexes.ISODates.IsMatch(dateandage))
return original;
bool AmericanDate = WikiRegexes.AmericanDates.IsMatch(dateandage);
// we have ISO date, convert with {{birth date and age}}, American date, set mf=y
return @"{{birth date and age|" + (AmericanDate ? "mf=y|" : "df=y|") + ISODate.Replace("-", "|") + @"}}";
}