Пример #1
0
        // Format: INT DATE (phrase)
        protected static string ParseIntDate(GDMDateInterpreted date, string strValue)
        {
            var strTok = new GEDCOMParser(strValue, false);

            // only standard GEDCOM dates (for owner == null)
            return(ParseIntDate(date, strTok));
        }
Пример #2
0
        // Format: INT DATE (phrase)
        protected static string ParseIntDate(GDMDateInterpreted date, GEDCOMParser strTok)
        {
            strTok.SkipWhitespaces();

            if (!strTok.RequireWord(GDMCustomDate.INT))
            {
                throw new GEDCOMIntDateException(strTok.GetFullStr());
            }
            strTok.Next();
            ParseDate(date, strTok);

            strTok.SkipWhitespaces();
            var token = strTok.CurrentToken;

            if (token == GEDCOMToken.Symbol && strTok.GetSymbol() == '(')
            {
                var phrase = new StringBuilder();
                phrase.Append(strTok.GetWord());
                do
                {
                    token = strTok.Next();
                    phrase.Append(strTok.GetWord());
                } while (token != GEDCOMToken.Symbol || strTok.GetSymbol() != ')');

                date.DatePhrase = phrase.ToString();
            }
            else
            {
                date.DatePhrase = string.Empty;
            }

            return(strTok.GetRest());
        }
Пример #3
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);
        }