/// <summary> /// Constructs an NhsDate object, uses NhsDate.ParseExact to create a new temporary NhsDate object for the given string /// and copies the property values from the temporary NhsDate object to the new NhsDate object. /// </summary> /// <param name="date">The date.</param> public NhsDate(string date) { NhsDate nd = NhsDate.ParseExact(date, CultureInfo.InvariantCulture); this.DateValue = nd.DateValue; this.DateType = nd.DateType; this.Month = nd.Month; this.Year = nd.Year; this.NullIndex = nd.NullIndex; }
/// <summary> /// Converts the given object to the type of the converter using the specified context and culture information. /// </summary> /// <param name="context">An ITypeDescriptorContext that provides a format context. </param> /// <param name="culture">CultureInfo culture. </param> /// <param name="value">The Object to be converted. </param> /// <returns>An Object that represents the converted value. </returns> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string stringValue = value as string; if (stringValue != null) { NhsDate date = NhsDate.ParseExact(stringValue, culture); return(date); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Parses a string that represents a date and returns a corresponding NhsDate object. /// </summary> /// <param name="date">The date to be parsed. </param> /// <returns>A new NhsDate object. </returns> /// <exception cref="System.ArgumentNullException">Date is null. </exception> /// <exception cref="System.FormatException">Date is not in a recognised format. </exception> public static NhsDate ParseExact(string date) { return(NhsDate.ParseExact(date, CultureInfo.CurrentCulture)); }