private static void RangeCheck(Person p, ref long lastBorn, ref long firstDead) { // Determine if a person is born later than existing history // Determine if a person is dead sooner? than existing history if (p == null) { return; } GEDDate birthDate = p.BirthDate; // uses estimated date if necessary if (birthDate != null) { lastBorn = Math.Max(lastBorn, birthDate.JDN); } if (p.Death != null && p.Death.GedDate != null && p.Death.GedDate.Type != GEDDate.Types.Unknown) { GEDDate dadBorn = p.Death.GedDate; if (dadBorn.JDN > firstDead) // TODO this looks wrong { firstDead = dadBorn.JDN; } } }
public void SecondKeyword() { string val = "FROM 17 May 1972 TO 25 May 1972"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Range, res.Type); Assert.AreEqual(1972, res.Year); Assert.AreEqual(5, res.Month); Assert.AreEqual(17, res.Day); Assert.IsFalse(res.IsBC); val = "BET 17 May 1972 AND 25 May 1972"; res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Range, res.Type); Assert.AreEqual(1972, res.Year); Assert.AreEqual(5, res.Month); Assert.AreEqual(17, res.Day); Assert.IsFalse(res.IsBC); val = "BET 17 May 1972 BLAH 25 May 1972"; res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); val = "FROM 17 May 1972 BLAH 25 May 1972"; res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); val = "BET 17 May 1972 TO 25 May 1972"; res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); val = "FROM 17 May 1972 AND 25 May 1972"; res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); }
private void Set(int day, int mon, int year, GEDDate.Types type, ref GEDDate tomod) { tomod.Day = day; // TODO may be invalid tomod.Month = mon; tomod.Year = year; // TODO may be invalid tomod.Type = type; }
public void Basic() { GEDDate res = new GEDDate(1, 4, 1975); Assert.IsTrue(res.Initialized); Assert.AreEqual(2442504, res.JDN); }
public void InvalidChar() { string val = "#@DGREGORIAN@ 17 May 1972"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); }
public void DayMon() { const string val = "25 Jul"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); }
private static long FirstOwnMarriage(Person p, out long firstSpouseBorn, out long firstChildBorn) { long firstOwnMarriage = long.MaxValue; firstSpouseBorn = long.MinValue; firstChildBorn = long.MinValue; foreach (var union in p._spouseIn) { long junk = 0; GEDDate md = union.MarriageDate; if (md != null && md.Type != GEDDate.Types.Unknown && md.JDN < firstOwnMarriage) { firstOwnMarriage = md.JDN; } if (union.Husband != p) // TODO 'otherspouse' accessor? { RangeCheck(union.Husband, ref firstSpouseBorn, ref junk); } else { RangeCheck(union.Wife, ref firstSpouseBorn, ref junk); } foreach (var child in union.Childs) { RangeCheck(child, ref firstChildBorn, ref junk); } } return(firstOwnMarriage); }
public void InvMon2() { const string val = "foo 1964"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); }
private static long EndToJulian(GEDDate gd) { int y = gd.Year; int m = gd.Month == -1 ? 12 : gd.Month; int d = gd.Day == -1 ? MonthEnd(m, y) : gd.Day; return(ToJulianDay(d, m, y, gd.IsBC)); }
private static long StartToJulian(GEDDate gd) { int m = gd.Month == -1 ? 1 : gd.Month; int d = gd.Day == -1 ? 1 : gd.Day; int y = gd.Year; return(ToJulianDay(d, m, y, gd.IsBC)); }
public void TestValidMonYear() { const string val = "Apr 1964"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Range, res.Type); Assert.AreEqual(1964, res.Year); Assert.AreEqual(4, res.Month); Assert.AreEqual(-1, res.Day); }
public void CantEst() { // one person, no birth date, no estimation possible var txt = "0 @I1@ INDI\n1 BIRT"; Forest f = Load(txt); GEDDate b = f.PersonById("I1").BirthDate; Assert.IsNull(b); }
public void TestValidDash() // 20171021 added symbol separator support { const string val = "13-Apr-1964"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1964, res.Year); Assert.AreEqual(4, res.Month); Assert.AreEqual(13, res.Day); }
public void ValidNonStdMonth() { const string val = "25 Jul. 1972"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1972, res.Year); Assert.AreEqual(7, res.Month); Assert.AreEqual(25, res.Day); }
public void ValidDayLongMonYear() { const string val = "25 December 1964"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1964, res.Year); Assert.AreEqual(12, res.Month); Assert.AreEqual(25, res.Day); }
public void ValidLongMonYear() { const string val = "December 1964"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Range, res.Type); Assert.AreEqual(1964, res.Year); Assert.AreEqual(12, res.Month); Assert.AreEqual(-1, res.Day); }
public void CantParse() { // one person, unparsable birth date, no estimation possible var txt = "0 @I1@ INDI\n1 BIRT\n2 DATE gibber"; Forest f = Load(txt); GEDDate b = f.PersonById("I1").BirthDate; Assert.IsNull(b); }
public void TestValid() { const string val = "13 Apr 1964"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1964, res.Year); Assert.AreEqual(4, res.Month); Assert.AreEqual(13, res.Day); }
private void TestEra(string era, bool shouldbebc) { string val = "17 May 1972"; GEDDate res = ParseForDate(val + era); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1972, res.Year); Assert.AreEqual(5, res.Month); Assert.AreEqual(17, res.Day); Assert.AreEqual(shouldbebc, res.IsBC, era); }
public void BasicCalendar2() { // specifying greg cal should have no impact string val = "@#DGREGORIAN 17 May 1972"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1972, res.Year); Assert.AreEqual(5, res.Month); Assert.AreEqual(17, res.Day); }
public void RealWorld() { // found during real GEDCOM testing string val = "1910 to 1920"; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Range, res.Type); Assert.AreEqual(1910, res.Year); // TODO verify range values }
public void InvalidSecondKeyword() { string val = "FROM 17 May 1972 TO "; GEDDate res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); val = "BET 17 May 1972 AND"; res = ParseForDate(val); Assert.AreEqual(GEDDate.Types.Unknown, res.Type); }
public void HWCantEst2() { // Husband+wife var txt = ComposePair("M", "F", false, "", "gibber"); var f = Load(txt); GEDDate b = f.PersonById("I1").BirthDate; Assert.IsNull(b); b = f.PersonById("I2").BirthDate; Assert.IsNull(b); }
public void NoEst() { // one person, valid birth date, no estimation necessary var txt = "0 @I1@ INDI\n1 BIRT\n2 DATE 1 APR 2011"; Forest f = Load(txt); GEDDate b = f.PersonById("I1").BirthDate; Assert.IsNotNull(b); Assert.AreNotEqual(GEDDate.Types.Estimated, b.Type); Assert.AreEqual(2455653, b.JDN); }
public void MCCantEst() { // Mother+child var txt = ComposePair("F", "F", true, "", ""); var f = Load(txt); GEDDate b = f.PersonById("I1").BirthDate; Assert.IsNull(b); b = f.PersonById("I2").BirthDate; Assert.IsNull(b); }
public void MCEstChild() { // Mother+child var txt = ComposePair("F", "F", true, "1 Apr 2011", "gibber"); var f = Load(txt); GEDDate b = f.PersonById("I1").BirthDate; Assert.IsNotNull(b); Assert.AreNotEqual(GEDDate.Types.Estimated, b.Type); Assert.AreEqual(2455653, b.JDN); b = f.PersonById("I2").BirthDate; Assert.IsNotNull(b); Assert.AreEqual(GEDDate.Types.Estimated, b.Type); }
public void HWEstHusb() { // Husband+wife var txt = ComposePair("M", "F", false, "gibber", "1 Apr 2011"); var f = Load(txt); GEDDate b = f.PersonById("I2").BirthDate; Assert.IsNotNull(b); Assert.AreNotEqual(GEDDate.Types.Estimated, b.Type); Assert.AreEqual(2455653, b.JDN); b = f.PersonById("I1").BirthDate; Assert.IsNotNull(b); Assert.AreEqual(GEDDate.Types.Estimated, b.Type); }
public void TwoGenEstC() { // Two generations, estimate from parent var txt = ComposeTwoGen("F", false, false, true); var f = Load(txt); GEDDate b = f.PersonById("I2").BirthDate; Assert.IsNotNull(b); Assert.AreNotEqual(GEDDate.Types.Estimated, b.Type); Assert.AreEqual(2455653, b.JDN); b = f.PersonById("I1").BirthDate; Assert.IsNotNull(b); Assert.AreEqual(GEDDate.Types.Estimated, b.Type); b = f.PersonById("I3").BirthDate; Assert.IsNotNull(b); Assert.AreEqual(GEDDate.Types.Estimated, b.Type); }
public void ValidAllLongMonths() { DateTime dt = new DateTime(1972, 1, 25); for (int i = 1; i <= 12; i++) { string str1 = dt.ToString("dd MMMM yyyy"); GEDDate res = ParseForDate(str1); Assert.AreEqual(GEDDate.Types.Exact, res.Type); Assert.AreEqual(1972, res.Year); Assert.AreEqual(i, res.Month); Assert.AreEqual(25, res.Day); dt = dt.AddMonths(1); } }
private void TestPrefix(string pref, GEDDate.Types target, bool?isStandard) { // TODO isStandard: verify flagged as (not)standard string val = "17 May 1972"; GEDDate res = ParseForDate(pref + val); Assert.AreEqual(target, res.Type, pref); if (!isStandard.HasValue) { return; // Couldn't parse: values not expected } Assert.AreEqual(1972, res.Year, pref); Assert.AreEqual(5, res.Month, pref); Assert.AreEqual(17, res.Day, pref); Assert.IsFalse(res.IsBC, pref); }