public DateTime ToDateTime() { FamilyDateType type = dateType; if (year <= 0) { trace.TraceInformation("Warning bad year!" + year); type = FamilyDateType.Unknown; } try { switch (type) { case FamilyDateType.YearMonthDay: return(new DateTime(year, month, day)); case FamilyDateType.YearMonth: return(new DateTime(year, month, 1)); case FamilyDateType.Year: return(new DateTime(year, 1, 1)); case FamilyDateType.DateString: case FamilyDateType.Unknown: default: return(new DateTime()); } } catch (ArgumentOutOfRangeException e) { trace.TraceInformation("Date type" + type + " " + year + "-" + month + "-" + day); trace.TraceInformation(e.ToString()); return(new DateTime()); } }
public FamilyDateTimeClass() { dateType = FamilyDateType.Unknown; timeType = FamilyTimeType.Unknown; approximate = false; badYear = false; }
public FamilyDateTimeClass(int inYear, int inMonth, int inDay) { dateType = FamilyDateType.YearMonthDay; year = inYear; month = inMonth; day = inDay; if (month < 1) { dateType = FamilyDateType.Year; } else if (day < 1) { dateType = FamilyDateType.YearMonth; } approximate = false; }
public FamilyDateTimeClass(int inYear = -1000, int inMonth = -1, int inDay = -1) { dateType = FamilyDateType.YearMonthDay; timeType = FamilyTimeType.Unknown; year = inYear; month = inMonth; day = inDay; if (month < 1) { dateType = FamilyDateType.Year; } else if (day < 1) { dateType = FamilyDateType.YearMonth; } approximate = false; badYear = false; }
public FamilyDateTimeClass(int inYear, String monthStr, int inDay) { dateType = FamilyDateType.YearMonthDay; year = inYear; switch (monthStr) { case "JAN": month = 1; break; case "FEB": month = 2; break; case "MAR": month = 3; break; case "APR": month = 4; break; case "MAY": month = 5; break; case "JUN": month = 6; break; case "JUL": month = 7; break; case "AUG": month = 8; break; case "SEP": month = 9; break; case "OCT": month = 10; break; case "NOV": month = 11; break; case "DEC": month = 12; break; default: trace.TraceInformation("Warning: Unknown month[" + monthStr + "]"); month = 0; break; } day = inDay; approximate = false; if (month == 0) { if (day != 0) { trace.TraceInformation("Warning: strange date:[" + monthStr + "]"); } dateType = FamilyDateTimeClass.FamilyDateType.Year; } }
public FamilyDateTimeClass(String inDateStr) { dateType = FamilyDateType.DateString; approximate = true; dateStr = inDateStr; }
public void SetDateType(FamilyDateType inType) { dateType = inType; }