/// <summary> /// Attempts to load the supplied FIX field value into this control. /// </summary> /// <param name="value">Value to set this control to.</param> /// <returns>true if it was possible to set the value of this control using the supplied value; false otherwise.</returns> protected override bool LoadDefaultFromFixValue(string value) { DateTime result; bool parsed = FixDateTime.TryParse(value, CultureInfo.InvariantCulture, out result); _value = parsed ? (DateTime?)result : null; return(parsed); }
/// <summary> /// Converts the value of this instance to an equivalent nullable DateTime value using the specified culture-specific formatting information. /// </summary> /// <param name="targetParameter">Target parameter for this conversion.</param> /// <param name="provider">An <see cref="IFormatProvider"/> interface implementation that supplies culture-specific formatting information.</param> /// <returns>A nullable DateTime equivalent to the value of this instance.</returns> public override DateTime?ToDateTime(IParameter targetParameter, IFormatProvider provider) { if (string.IsNullOrEmpty(_value)) { return(null); } DateTime result; if (!FixDateTime.TryParse(_value, provider, out result)) { throw ThrowHelper.New <InvalidCastException>(this, ErrorMessages.InvalidDateOrTimeValue, _value); } return(result); }