Ejemplo n.º 1
0
        public GDMSourceCitationData()
        {
            SetName(GEDCOMTagType.DATA);

            fDate = new GDMDateValue();
            fText = new GDMTextTag((int)GEDCOMTagType.TEXT);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This function compares dates only by chronological year.
        /// Month and day are not taken into account, the year is compared with the calendar.
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="matchParams"></param>
        /// <returns></returns>
        public override float IsMatch(GDMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GDMDateValue date = (GDMDateValue)tag;

            if (IsEmpty() || date.IsEmpty())
            {
                return(0.0f);
            }

            int absVal1 = this.GetChronologicalYear();
            int absVal2 = date.GetChronologicalYear();

            float match   = 0.0f;
            float matches = 0.0f;

            if (absVal1 != 0 && absVal2 != 0)
            {
                matches += 1.0f;
                if (Math.Abs(absVal1 - absVal2) <= matchParams.YearsInaccuracy)
                {
                    match += 100.0f;
                }
            }

            return(match / matches);
        }
Ejemplo n.º 3
0
 protected GDMCustomEvent(GDMObject owner) : base(owner)
 {
     fAddress         = new GDMAddress(this);
     fDate            = new GDMDateValue(this);
     fPlace           = new GDMPlace(this);
     fNotes           = new GDMList <GDMNotes>(this);
     fSourceCitations = new GDMList <GDMSourceCitation>(this);
     fMultimediaLinks = new GDMList <GDMMultimediaLink>(this);
 }
Ejemplo n.º 4
0
 protected GDMCustomEvent()
 {
     fAddress         = new GDMAddress();
     fDate            = new GDMDateValue();
     fPlace           = new GDMPlace();
     fNotes           = new GDMList <GDMNotes>();
     fSourceCitations = new GDMList <GDMSourceCitation>();
     fMultimediaLinks = new GDMList <GDMMultimediaLink>();
 }
Ejemplo n.º 5
0
        public void Test_UDN()
        {
            UDN emptyUDN = UDN.CreateEmpty();

            Assert.IsTrue(emptyUDN.IsEmpty());

            // BIRT: "28 DEC 1990"
            GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord;

            UDN testUDN = iRec.GetUDN(GEDCOMTagName.BIRT);

            Assert.AreEqual("1990/12/28", testUDN.ToString());

            testUDN = GDMDate.GetUDNByFormattedStr("28/12/1990", GDMCalendar.dcGregorian);
            Assert.AreEqual("1990/12/28", testUDN.ToString());

            using (GDMDateValue dateVal = new GDMDateValue()) {
                dateVal.ParseString("28 DEC 1990");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual("1990/12/28", testUDN.ToString());

                dateVal.ParseString("ABT 20 JAN 2013");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual("~2013/01/20", testUDN.ToString());

                dateVal.ParseString("CAL 20 JAN 2013");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual("~2013/01/20", testUDN.ToString());

                dateVal.ParseString("EST 20 DEC 2013");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual("~2013/12/20", testUDN.ToString());

                dateVal.ParseString("BET 04 JAN 2013 AND 25 JAN 2013");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual("2013/01/14", testUDN.ToString());

                dateVal.ParseString("BEF 20 JAN 2013");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual("<2013/01/20", testUDN.ToString());

                dateVal.ParseString("AFT 20 JAN 2013");
                testUDN = dateVal.GetUDN();
                Assert.AreEqual(">2013/01/20", testUDN.ToString());
            }
        }
Ejemplo n.º 6
0
        public override float IsMatch(GDMTag tag, MatchParams matchParams)
        {
            if (tag == null)
            {
                return(0.0f);
            }
            GDMCustomEvent ev = (GDMCustomEvent)tag;

            // match date
            float dateMatch = 0.0f;
            float locMatch  = 0.0f;
            int   matches   = 0;

            GDMDateValue dtVal  = this.Date;
            GDMDateValue dtVal2 = ev.Date;

            matches += 1;
            if (dtVal != null && dtVal2 != null)
            {
                dateMatch = dtVal.IsMatch(dtVal2, matchParams);
            }

            // match location - late code-on by option implementation
            if (matchParams.CheckEventPlaces)
            {
                matches += 1;

                if (!this.HasPlace && !ev.HasPlace)
                {
                    locMatch = 100.0f;
                }
                else if (this.HasPlace && ev.HasPlace && this.Place.StringValue == ev.Place.StringValue)
                {
                    locMatch = 100.0f;
                }
            }

            float match = (dateMatch + locMatch) / matches;

            return(match);
        }
Ejemplo n.º 7
0
 protected GDMCustomEvent()
 {
     fDate = new GDMDateValue();
 }
Ejemplo n.º 8
0
        public void Test_Common()
        {
            // check empty dateval match
            using (GDMDateValue dtx1 = new GDMDateValue(null)) {
                Assert.IsNotNull(dtx1, "dtx1 != null");

                using (GDMDateValue dtx2 = new GDMDateValue(null)) {
                    Assert.IsNotNull(dtx2, "dtx1 != null");

                    Assert.AreEqual(0.0f, dtx1.IsMatch(dtx2, new MatchParams()));
                }
            }

            using (GDMDateValue dtx1 = new GDMDateValue(null)) {
                Assert.IsNotNull(dtx1, "dtx1 != null");
                Assert.AreEqual("", dtx1.GetDisplayStringExt(DateFormat.dfYYYY_MM_DD, true, true)); // value is empty

                dtx1.ParseString("20 JAN 2013");
                Assert.AreEqual("2013.01.20 [G]", dtx1.GetDisplayStringExt(DateFormat.dfYYYY_MM_DD, true, true));
            }

            using (GDMDateValue dtx1 = new GDMDateValue(null)) {
                Assert.IsNotNull(dtx1, "dtx1 != null");
                dtx1.ParseString("20 JAN 2013");

                DateTime dt = TestUtils.ParseDT("20.01.2013");
                Assert.IsTrue(dtx1.Date.Equals(dt), "dtx1.DateTime.Equals(dt)");

                dtx1.ParseString("1716/"); // potentially incorrect value
                Assert.AreEqual("1716", dtx1.StringValue);

                dtx1.ParseString("1716/1717");
                Assert.AreEqual("1716/1717", dtx1.StringValue);

                dtx1.ParseString("1716/20");
                Assert.AreEqual("1716/20", dtx1.StringValue);

                dtx1.ParseString("3 MAY 1835/1838");
                Assert.AreEqual("03 MAY 1835/1838", dtx1.StringValue);

                dtx1.ParseString("ABT 1844/1845");
                Assert.AreEqual("ABT 1844/1845", dtx1.StringValue);

                dtx1.ParseString("FEB 1746/1747");
                Assert.AreEqual("FEB 1746/1747", dtx1.StringValue);

                dtx1.ParseString("INT 20 JAN 2013 (today)");
                Assert.IsTrue(dtx1.Date.Equals(dt), "dtx1.DateTime.Equals(dt)");
                Assert.AreEqual("today", (dtx1.Value as GDMDateInterpreted).DatePhrase);

                (dtx1.Value as GDMDateInterpreted).DatePhrase = "now";
                Assert.AreEqual("INT 20 JAN 2013 (now)", dtx1.StringValue);

                (dtx1.Value as GDMDateInterpreted).DatePhrase = "(yesterday)";
                Assert.AreEqual("INT 20 JAN 2013 (yesterday)", dtx1.StringValue);

                dtx1.ParseString("INT 20 JAN 2013 (yesterday)");
                Assert.AreEqual("INT 20 JAN 2013 (yesterday)", dtx1.StringValue);

                string st;

                st = "ABT 20 JAN 2013";
                dtx1.ParseString(st);
                Assert.IsTrue(dtx1.Date.Equals(dt));
                Assert.AreEqual(st, dtx1.StringValue);
                Assert.AreEqual(GDMApproximated.daAbout, ((GDMDate)dtx1.Value).Approximated);

                st = "CAL 20 JAN 2013";
                dtx1.ParseString(st);
                Assert.AreEqual(dtx1.Date, dt);
                Assert.AreEqual(st, dtx1.StringValue);
                Assert.AreEqual(GDMApproximated.daCalculated, ((GDMDate)dtx1.Value).Approximated);

                st = "EST 20 DEC 2013";
                dtx1.ParseString(st);
                Assert.AreEqual(dtx1.Date, TestUtils.ParseDT("20.12.2013"));
                Assert.AreEqual(st, dtx1.StringValue);
                Assert.AreEqual(GDMApproximated.daEstimated, ((GDMDate)dtx1.Value).Approximated);

                ((GDMDate)dtx1.Value).Approximated = GDMApproximated.daCalculated;
                Assert.AreEqual("CAL 20 DEC 2013", dtx1.StringValue);

                ((GDMDate)dtx1.Value).Approximated = GDMApproximated.daExact;
                Assert.AreEqual("20 DEC 2013", dtx1.StringValue);

                using (GDMDateValue dtx2 = new GDMDateValue(null)) {
                    dtx2.ParseString("19 JAN 2013");
                    int res = dtx1.CompareTo(dtx2);
                    Assert.AreEqual(1, res);
                }

                int res1 = dtx1.CompareTo(null);
                Assert.AreEqual(-1, res1);

                //

                dtx1.ParseString("FROM 04 JAN 2013 TO 23 JAN 2013");
                Assert.IsFalse(dtx1.IsEmpty());
                Assert.AreEqual("FROM 04 JAN 2013 TO 23 JAN 2013", dtx1.StringValue);
                Assert.AreEqual("04 JAN 2013", (dtx1.Value as GDMDatePeriod).DateFrom.StringValue);
                Assert.AreEqual("23 JAN 2013", (dtx1.Value as GDMDatePeriod).DateTo.StringValue);
                dtx1.Clear();
                Assert.IsTrue(dtx1.IsEmpty());

                dtx1.ParseString("BEF 20 JAN 2013");
                Assert.IsFalse(dtx1.IsEmpty());
                Assert.AreEqual(TestUtils.ParseDT("20.01.2013"), dtx1.Date);
                Assert.AreEqual("BEF 20 JAN 2013", dtx1.StringValue);

                dtx1.ParseString("AFT 20 JAN 2013");
                Assert.IsFalse(dtx1.IsEmpty());
                Assert.AreEqual(TestUtils.ParseDT("20.01.2013"), dtx1.Date);
                Assert.AreEqual("AFT 20 JAN 2013", dtx1.StringValue);

                dtx1.ParseString("BET 04 JAN 2013 AND 25 JAN 2013");
                Assert.IsFalse(dtx1.IsEmpty());
                Assert.AreEqual("BET 04 JAN 2013 AND 25 JAN 2013", dtx1.StringValue);
                Assert.AreEqual("04 JAN 2013", (dtx1.Value as GDMDateRange).After.StringValue);
                Assert.AreEqual("25 JAN 2013", (dtx1.Value as GDMDateRange).Before.StringValue);
                dtx1.Clear();
                Assert.IsTrue(dtx1.IsEmpty());
            }
        }
Ejemplo n.º 9
0
 protected GDMCustomEvent(GDMObject owner) : base(owner)
 {
     fAddress = new GDMAddress(this);
     fDate    = new GDMDateValue(this);
     fPlace   = new GDMPlace(this);
 }