public void Value__Set_to_Valid_Year() { var commonDt = new CommonDT(); commonDt.Value = "2001"; Assert.AreEqual("2001", commonDt.Value); Assert.AreEqual(2001, commonDt.Year); }
/// <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> /// /// <exception cref="DataTypeException"> Thrown when a Data Type error condition occurs. </exception> /// /// <param name="yr"> The yr. </param> /// <param name="mnth"> The mnth. </param> /// <param name="dy"> The dy. </param> public virtual void setDatePrecision(int yr, int mnth, int dy) { try { //create date object if there isn't one if (this.dt == null) { this.dt = new CommonDT(); } //set the value of the date object to the input date value this.dt.setYearMonthDayPrecision(yr, mnth, dy); //clear the time value object this.tm = null; } //end try catch (DataTypeException e) { throw e; } //end catch catch (System.Exception e) { throw new DataTypeException("An unexpected exception ocurred", 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) { String val = ""; try { //set the input cal object so that it can report errors //on it's value int calYear = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR); int calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1; int calDay = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH); CommonDT 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 ocurred", e); } return(val); }
public void Value__Set_to_Valid_Year_and_Month() { var commonDt = new CommonDT(); commonDt.Value = "200102"; Assert.AreEqual("200102", commonDt.Value); Assert.AreEqual(2001, commonDt.Year); Assert.AreEqual(2, commonDt.Month); }
public void Value__Set_to_Invalid_Year() { var commonDt = new CommonDT(); commonDt.Value = "200a"; }
public void Value__Set_to_Invalid_Length() { var commonDt = new CommonDT(); commonDt.Value = "20010"; }
public void Value__Set_to_Empty_Quoted_String() { var commonDt = new CommonDT(); commonDt.Value = "\"\""; Assert.AreEqual("\"\"", commonDt.Value); }
public void Value__Set_to_Null() { var commonDt = new CommonDT(); commonDt.Value = null; Assert.AreEqual(null, commonDt.Value); }
/// <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 (System.Exception e) { throw new DataTypeException("An unexpected exception ocurred", e); } //end catch }
public void setYearMonthDayPrecision_With_Valid_Year_and_Month_and_Day() { var commonDt = new CommonDT(); commonDt.setYearMonthDayPrecision(2001, 2, 3); Assert.AreEqual("20010203", commonDt.Value); Assert.AreEqual(2001, commonDt.Year); Assert.AreEqual(2, commonDt.Month); Assert.AreEqual(3, commonDt.Day); }
public void setYearMonthPrecision_With_Invalid_Month() { var commonDt = new CommonDT(); commonDt.setYearMonthPrecision(2001, 13); }
public void setYearMonthPrecision_With_Valid_Year_and_Month() { var commonDt = new CommonDT(); commonDt.setYearMonthPrecision(2001, 02); Assert.AreEqual("200102", commonDt.Value); Assert.AreEqual(2001, commonDt.Year); Assert.AreEqual(2, commonDt.Month); }
public void YearPrecision__Set_to_Invalid_Year() { var commonDt = new CommonDT(); commonDt.YearPrecision = 20010; }
public void YearPrecision__Set_to_Valid_Year() { var commonDt = new CommonDT(); commonDt.YearPrecision = 2001; Assert.AreEqual("2001", commonDt.Value); Assert.AreEqual(2001, commonDt.Year); Assert.AreEqual(0, commonDt.Month); Assert.AreEqual(0, commonDt.Day); }
public void Constructor_Sets_Value() { var commonDt = new CommonDT("20010203"); Assert.AreEqual("20010203", commonDt.Value); }
public void Value__Set_to_Invalid_Day() { var commonDt = new CommonDT(); commonDt.Value = "2001020a"; }
public void setYearMonthDayPrecision_With_Invalid_Day() { var commonDt = new CommonDT(); commonDt.setYearMonthDayPrecision(2001, 2, 29); }
/// <summary> Returns a string value representing the input Gregorian Calendar object in /// an Hl7 Date Format. /// </summary> public static System.String toHl7DTFormat(System.Globalization.GregorianCalendar cal) { System.String val = ""; try { //set the input cal object so that it can report errors //on it's value int calYear = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.YEAR); int calMonth = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.MONTH) + 1; int calDay = SupportClass.CalendarManager.manager.Get(cal, SupportClass.CalendarManager.DAY_OF_MONTH); CommonDT dt = new CommonDT(); dt.setYearMonthDayPrecision(calYear, calMonth, calDay); val = dt.Value; } catch (DataTypeException e) { throw e; } catch (System.Exception e) { throw new DataTypeException("An unexpected exception ocurred", e); } return val; }