Esempio n. 1
0
        // Format: AFT DATE | BEF DATE | BET AFT_DATE AND BEF_DATE
        protected static string ParseRangeDate(GDMDateRange date, string strValue)
        {
            var strTok = new GEDCOMParser(strValue, false);

            // only standard GEDCOM dates (for owner == null)
            return(ParseRangeDate(date, strTok));
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public static GDMDateRange CreateRange(GDMDate dateAfter, GDMDate dateBefore)
        {
            GDMDateRange result = new GDMDateRange();

            if (dateAfter != null)
            {
                result.After.Assign(dateAfter);
            }
            if (dateBefore != null)
            {
                result.Before.Assign(dateBefore);
            }
            return(result);
        }
Esempio n. 4
0
        // Format: AFT DATE | BEF DATE | BET AFT_DATE AND BEF_DATE
        protected static string ParseRangeDate(GDMDateRange date, GEDCOMParser strTok)
        {
            strTok.SkipWhitespaces();

            var token = strTok.CurrentToken;

            if (token != GEDCOMToken.Word)
            {
                // error!
            }
            string su       = strTok.GetWord();
            int    dateType = Algorithms.BinarySearch(GDMCustomDate.GEDCOMDateRangeArray, su, string.CompareOrdinal);

            if (dateType == 0)   // "AFT"
            {
                strTok.Next();
                ParseDate(date.After, strTok);
            }
            else if (dateType == 1)     // "BEF"
            {
                strTok.Next();
                ParseDate(date.Before, strTok);
            }
            else if (dateType == 2)     // "BET"
            {
                strTok.Next();
                ParseDate(date.After, strTok);
                strTok.SkipWhitespaces();

                if (!strTok.RequireWord(GDMCustomDate.GEDCOMDateRangeArray[3]))   // "AND"
                {
                    throw new GEDCOMRangeDateException(strTok.GetFullStr());
                }

                strTok.Next();
                strTok.SkipWhitespaces();
                ParseDate(date.Before, strTok);
            }

            return(strTok.GetRest());
        }