public FixDateOrdinalsAndOf ( string articleText, string articleTitle ) : string | ||
articleText | string | The wiki text of the article |
articleTitle | string | The article's title |
return | string |
/// <summary> /// takes input string of date and age e.g. "11 May 1990 (age 21)" and converts to {{birth date and age|1990|5|11}} /// </summary> /// <param name="dateandage"></param> /// <returns></returns> 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, ""); bool AmericanDate = WikiRegexes.AmericanDates.IsMatch(dateandage); string ISODate = Tools.ConvertDate(dateandage, DateLocale.ISO); if (ISODate.Equals(dateandage) && !WikiRegexes.ISODates.IsMatch(dateandage)) return original; // 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("-", "|") + @"}}"; }