/// <summary> /// Adds a date field to the current active message. Please note that all dates and times are expressed in UTC. The format of value must be one of "YYYY-MM-DD", "YYYY-MM", "YYYY-H1", "YYYY-H2", "YYYY-T1", "YYYY-T2", "YYYY-T3", "YYYY-Q1", "YYYY-Q2", "YYYY-Q3", "YYYYQ4" or "YYYY-W[1-52]". /// </summary> /// <param name="tag">The field tag.</param> /// <param name="value">The date field value.</param> /// <returns><see langword="true" /> if the field was successfully added, or <see langword="false" /> if the value could not be added (because there was no more memory, the message handle does not contain any messages, or the supplied value is not of the type specified).</returns> /// <exception cref="ObjectDisposedException">The <see cref="Message"/> instance has been disposed.</exception> /// <remarks>The corresponding native function is mdf_message_add_date.</remarks> public bool AddDate(uint tag, string value) { ThrowIfDisposed(); if (value == null) { return(_nativeImplementation.mdf_message_add_date(Handle, tag, IntPtr.Zero) == 1); } byte *bytes = stackalloc byte[value.Length + 1]; if (!TryGetAsciiBytes(value, bytes)) { return(false); } return(_nativeImplementation.mdf_message_add_date(Handle, tag, (IntPtr)bytes) == 1); }