Beispiel #1
0
        // Format: FROM DATE1 TO DATE2
        protected static string ParsePeriodDate(GDMDatePeriod date, string strValue)
        {
            var strTok = new GEDCOMParser(strValue, false);

            // only standard GEDCOM dates (for owner == null)
            return(ParsePeriodDate(date, strTok));
        }
Beispiel #2
0
        // DateValue format: INT/FROM/TO/etc..._<date>
        protected static string ParseDateValue(GDMDateValue dateValue, string str)
        {
            if (str == null)
            {
                return(string.Empty);
            }

            var strTok = new GEDCOMParser(str, false);

            strTok.SkipWhitespaces();

            int idx   = 0;
            var token = strTok.CurrentToken;

            if (token == GEDCOMToken.Word)
            {
                string su = strTok.GetWord();
                idx = Algorithms.BinarySearch(GDMCustomDate.GEDCOMDateTypes, su, string.CompareOrdinal);
            }
            var dateType = (idx < 0) ? GEDCOMDateType.SIMP : (GEDCOMDateType)idx;

            string        result;
            GDMCustomDate date;

            switch (dateType)
            {
            case GEDCOMDateType.AFT:
            case GEDCOMDateType.BEF:
            case GEDCOMDateType.BET:
                date   = new GDMDateRange();
                result = ParseRangeDate((GDMDateRange)date, strTok);
                break;

            case GEDCOMDateType.INT:
                date   = new GDMDateInterpreted();
                result = ParseIntDate((GDMDateInterpreted)date, strTok);
                break;

            case GEDCOMDateType.FROM:
            case GEDCOMDateType.TO:
                date   = new GDMDatePeriod();
                result = ParsePeriodDate((GDMDatePeriod)date, strTok);
                break;

            default:
                date   = new GDMDate();
                result = ParseDate((GDMDate)date, strTok);
                break;
            }

            dateValue.SetRawData(date);
            return(result);
        }
Beispiel #3
0
        public static GDMDatePeriod CreatePeriod(GDMDate dateFrom, GDMDate dateTo)
        {
            GDMDatePeriod result = new GDMDatePeriod();

            if (dateFrom != null)
            {
                result.DateFrom.Assign(dateFrom);
            }
            if (dateTo != null)
            {
                result.DateTo.Assign(dateTo);
            }
            return(result);
        }
Beispiel #4
0
        // Format: FROM DATE1 TO DATE2
        protected static string ParsePeriodDate(GDMDatePeriod date, GEDCOMParser strTok)
        {
            strTok.SkipWhitespaces();

            if (strTok.RequireWord(GDMCustomDate.FROM))
            {
                strTok.Next();
                ParseDate(date.DateFrom, strTok);
                strTok.SkipWhitespaces();
            }

            if (strTok.RequireWord(GDMCustomDate.TO))
            {
                strTok.Next();
                ParseDate(date.DateTo, strTok);
                strTok.SkipWhitespaces();
            }

            return(strTok.GetRest());
        }