/// <summary> /// Converts a string value into a SmartDate. /// </summary> /// <param name="value">String containing the date value.</param> /// <param name="emptyValue">Indicates whether an empty date is the min or max date value.</param> /// <param name="result">The resulting SmartDate value if the parse was successful.</param> /// <returns>A value indicating if the parse was successful.</returns> public static bool TryParse(string value, EmptyValue emptyValue, ref SmartDate result) { System.DateTime dateResult = DateTime.MinValue; if (TryStringToDate(value, emptyValue, ref dateResult)) { result = new SmartDate(dateResult, emptyValue); return true; } else { return false; } }
/// <summary> /// Compares one SmartDate to another. /// </summary> /// <remarks> /// This method works the same as the DateTime.CompareTo method /// on the Date datetype, with the exception that it /// understands the concept of empty date values. /// </remarks> /// <param name="value">The date to which we are being compared.</param> /// <returns>A value indicating if the comparison date is less than, equal to or greater than this date.</returns> public int CompareTo(SmartDate value) { if (this.IsEmpty && value.IsEmpty) return 0; else return _date.CompareTo(value.Date); }
/// <summary> /// Converts a string value into a SmartDate. /// </summary> /// <param name="value">String containing the date value.</param> /// <param name="result">The resulting SmartDate value if the parse was successful.</param> /// <returns>A value indicating if the parse was successful.</returns> public static bool TryParse(string value, ref SmartDate result) { return TryParse(value, EmptyValue.MinDate, ref result); }