// Gets a parameter of the given name and attempts to extract a date. // Returns null if the parameter is not present or the format is incorrect. private DateTimeOffset?GetDate(string parameter) { var dateParameter = NameValueHeaderValue.Find(_parameters, parameter); if (dateParameter != null) { string dateString = dateParameter.Value; // Should have quotes, remove them. if (IsQuoted(dateString)) { dateString = dateString.Substring(1, dateString.Length - 2); } DateTimeOffset date; if (HttpRuleParser.TryStringToDate(dateString, out date)) { return(date); } } return(null); }
public static bool TryParseDate(string input, out DateTimeOffset result) { return(HttpRuleParser.TryStringToDate(input, out result)); }