/// <summary> This method takes in integer values for the year and month and day /// and performs validations, it then sets the value in the object /// formatted as an HL7 Time Stamp value with year and month and day precision (YYYYMMDD). /// /// </summary> public virtual void SetDatePrecision(int yr, int mnth, int dy) { try { // create date object if there isn't one if (dt == null) { dt = new CommonDT(); } // set the value of the date object to the input date value dt.SetYearMonthDayPrecision(yr, mnth, dy); // clear the time value object tm = null; } // end try catch (DataTypeException e) { throw e; } // end catch catch (Exception e) { throw new DataTypeException("An unexpected exception occurred", e); } // end catch }
/// <summary> Returns a string value representing the input Gregorian Calendar object in /// an Hl7 Date Format. /// </summary> public static string ToHl7DTFormat(GregorianCalendar cal) { var val = string.Empty; try { // set the input cal object so that it can report errors // on it's value var calYear = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR); var calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1; var calDay = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH); var dt = new CommonDT(); dt.SetYearMonthDayPrecision(calYear, calMonth, calDay); val = dt.Value; } catch (DataTypeException e) { throw e; } catch (Exception e) { throw new DataTypeException("An unexpected exception occurred", e); } return(val); }