Пример #1
0
        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());
            }
        }
Пример #2
0
 public FamilyDateTimeClass()
 {
     dateType    = FamilyDateType.Unknown;
     timeType    = FamilyTimeType.Unknown;
     approximate = false;
     badYear     = false;
 }
Пример #3
0
 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;
 }
Пример #4
0
 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;
 }
Пример #5
0
        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;
            }
        }
Пример #6
0
 public FamilyDateTimeClass(String inDateStr)
 {
     dateType    = FamilyDateType.DateString;
     approximate = true;
     dateStr     = inDateStr;
 }
Пример #7
0
 public void SetDateType(FamilyDateType inType)
 {
     dateType = inType;
 }