/// <summary> /// Parses a string that represents a date and returns a corresponding CuiDate object, with the culture /// used to parse the string specified. /// </summary> /// <param name="date">The date to be parsed.</param> /// <param name="cultureInfo">The culture that should be used to parse the string. If a string is culture-agnostic, /// this should be CultureInfo.InvariantCulture. Defaults to CurrentCulture.</param> /// <returns>A new CuiDate object. </returns> /// <exception cref="System.ArgumentNullException">Date is null. </exception> /// <exception cref="System.FormatException">Date is not in a recognised format.</exception> public static CuiDate ParseExact(string date, CultureInfo cultureInfo) { CuiDate result; if (!CuiDate.TryParseExact(date, out result, cultureInfo)) { throw new FormatException(Resources.CuiDateResources.ParseCalledWithBadFormat); } return(result); }
/// <summary> /// Parses a string that represents a date. /// </summary> /// <param name="date">A string containing the value to be parsed. </param> /// <param name="result">A container for a successfully-parsed date. </param> /// <returns>True if the date string was successfully parsed; otherwise, false.</returns> /// <remarks> /// If the string can be parsed, /// the result parameter is set to an CuiDate object corresponding to /// the parsed dateString. If the string cannot be parsed, the result parameter is set to DateTime.MinValue. /// </remarks> public static bool TryParseExact(string date, out CuiDate result) { return(CuiDate.TryParseExact(date, out result, CultureInfo.InvariantCulture)); }