Beispiel #1
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());
        }
Beispiel #2
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());
        }