示例#1
0
        /// <summary>
        /// Sets the date of this timestamp with the specified precision.
        /// </summary>
        /// <param name="dateTime">Date/time value or null</param>
        /// <param name="precision">Precision format (year, month, day, hour, minute, 1 second, 100 milliseconds, 10 milliseconds, 1 milliseconds or 100 nanoseconds, with or without time zone)</param>
        public void SetDateTime(DateTime?dateTime, HL7DateTimePrecision precision)
        {
            timeofanevent = HL7DateTime.ToString(dateTime, precision);

            // the precision is indicated by limiting the number of digits used, not using degreeofprecision.
            degreeofprecision = null;
        }
示例#2
0
 /// <summary>
 /// Converts a DateTime to an HL7 timestamp string, using the given precision.
 /// </summary>
 /// <param name="value">A DateTime value.</param>
 /// <param name="precision">The desired precision and whether to include the time zone offset.</param>
 /// <returns>An HL7 timestamp string.</returns>
 public static string ToString(DateTime?value, HL7DateTimePrecision precision)
 {
     if (value.HasValue)
     {
         string format = precision.GetAttributeValue <HL7DateTimeFormat, string>(a => a.Format);
         return(value.Value.ToString(format).Replace(":", ""));
     }
     return(string.Empty);
 }