/// <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); }
public override bool IsEmpty() { return(base.IsEmpty() && fAddress.IsEmpty() && string.IsNullOrEmpty(fAgency) && string.IsNullOrEmpty(fCause) && string.IsNullOrEmpty(fClassification) && fDate.IsEmpty() && fPlace.IsEmpty() && string.IsNullOrEmpty(fReligiousAffilation) && (fRestriction == GDMRestriction.rnNone) && (fNotes.Count == 0) && (fSourceCitations.Count == 0) && (fMultimediaLinks.Count == 0)); }
public override bool IsEmpty() { return(base.IsEmpty() && fDate.IsEmpty() && fText.IsEmpty()); }
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()); } }
public override bool IsEmpty() { return(base.IsEmpty() && fAddress.IsEmpty() && string.IsNullOrEmpty(fAgency) && string.IsNullOrEmpty(fCause) && string.IsNullOrEmpty(fClassification) && fDate.IsEmpty() && fPlace.IsEmpty() && string.IsNullOrEmpty(fReligiousAffilation) && fRestriction == GDMRestriction.rnNone); }