diff --git a/projects/GKCore/GDModel/GDMIndividualRecord.cs b/projects/GKCore/GDModel/GDMIndividualRecord.cs index f66128c13..4163c6f78 100644 --- a/projects/GKCore/GDModel/GDMIndividualRecord.cs +++ b/projects/GKCore/GDModel/GDMIndividualRecord.cs @@ -390,7 +390,7 @@ public override void ReplaceXRefs(GDMXRefReplacer map) fSpouseToFamilyLinks.ReplaceXRefs(map); } - public sealed class LifeDatesRet + public sealed class LifeEvents { public readonly GDMCustomEvent BirthEvent; public readonly GDMCustomEvent DeathEvent; @@ -398,7 +398,7 @@ public sealed class LifeDatesRet public readonly GDMCustomEvent BaptismEvent; public readonly GDMCustomEvent BurialEvent; - public LifeDatesRet(GDMCustomEvent birthEvent, GDMCustomEvent deathEvent, GDMCustomEvent baptismEvent, GDMCustomEvent burialEvent) + public LifeEvents(GDMCustomEvent birthEvent, GDMCustomEvent deathEvent, GDMCustomEvent baptismEvent, GDMCustomEvent burialEvent) { BirthEvent = birthEvent; DeathEvent = deathEvent; @@ -407,7 +407,7 @@ public LifeDatesRet(GDMCustomEvent birthEvent, GDMCustomEvent deathEvent, GDMCus } } - public LifeDatesRet GetLifeDates(bool ext = false) + public LifeEvents GetLifeEvents(bool ext = false) { GDMCustomEvent birthEvent = null; GDMCustomEvent deathEvent = null; @@ -432,7 +432,7 @@ public LifeDatesRet GetLifeDates(bool ext = false) } } - return new LifeDatesRet(birthEvent, deathEvent, baptismEvent, burialEvent); + return new LifeEvents(birthEvent, deathEvent, baptismEvent, burialEvent); } public GDMPersonalName GetPrimaryPersonalName() @@ -500,8 +500,8 @@ public override float IsMatch(GDMTag tag, MatchParams matchParams) // 0% name match would be pointless checking other details if (nameMatch != 0.0f && matchParams.DatesCheck) { - var dates = GetLifeDates(); - var indiDates = indi.GetLifeDates(); + var dates = GetLifeEvents(); + var indiDates = indi.GetLifeEvents(); if (dates.BirthEvent != null && indiDates.BirthEvent != null) { birthMatch = dates.BirthEvent.IsMatch(indiDates.BirthEvent, matchParams); diff --git a/projects/GKCore/GKCore/BaseContext.cs b/projects/GKCore/GKCore/BaseContext.cs index 18950e7fb..23cb7709f 100644 --- a/projects/GKCore/GKCore/BaseContext.cs +++ b/projects/GKCore/GKCore/BaseContext.cs @@ -591,13 +591,27 @@ public void CollectTips(StringList tipsList) throw new ArgumentNullException("tipsList"); try { + bool onlyAlive = true; + var dtNow = DateTime.Now; + bool firstTip = true; var indiEnum = fTree.GetEnumerator(); GDMIndividualRecord iRec; while (indiEnum.MoveNext(out iRec)) { + var lifeEvents = iRec.GetLifeEvents(true); + + if (onlyAlive) { + if (lifeEvents.DeathEvent != null || lifeEvents.BurialEvent != null) continue; + } + int years; bool anniversary; - int days = GKUtils.GetDaysForBirth(iRec, true, out years, out anniversary); + + if (lifeEvents.BirthEvent == null) continue; + var dt = lifeEvents.BirthEvent.Date.Value as GDMDate; + if (dt == null || !dt.IsValidDate()) continue; + + int days = GKUtils.GetDaysFor(dt, dtNow, out years, out anniversary); if (days < 0 || days >= 3) continue; if (firstTip) { diff --git a/projects/GKCore/GKCore/Charts/TreeChartPerson.cs b/projects/GKCore/GKCore/Charts/TreeChartPerson.cs index a371eaa46..dbb66cc28 100644 --- a/projects/GKCore/GKCore/Charts/TreeChartPerson.cs +++ b/projects/GKCore/GKCore/Charts/TreeChartPerson.cs @@ -298,7 +298,7 @@ public void BuildBy(GDMIndividualRecord iRec) TreeChartOptions options = fModel.Options; - var lifeDates = iRec.GetLifeDates(true); + var lifeDates = iRec.GetLifeEvents(true); GDMCustomEvent birthEvent = lifeDates.BirthEvent; GDMCustomEvent deathEvent = lifeDates.DeathEvent; string birthSign = ImportUtils.STD_BIRTH_SIGN; diff --git a/projects/GKCore/GKCore/GKUtils.cs b/projects/GKCore/GKCore/GKUtils.cs index 385777b98..7bd293075 100644 --- a/projects/GKCore/GKCore/GKUtils.cs +++ b/projects/GKCore/GKCore/GKUtils.cs @@ -1228,7 +1228,7 @@ public static int GetLifeExpectancy(GDMIndividualRecord iRec) if (iRec == null) return result; try { - var lifeDates = iRec.GetLifeDates(); + var lifeDates = iRec.GetLifeEvents(); result = GetEventsYearsDiff(lifeDates.BirthEvent, lifeDates.DeathEvent, false); } catch (Exception ex) { Logger.WriteError("GKUtils.GetLifeExpectancy()", ex); @@ -1249,7 +1249,7 @@ public static int GetAge(GDMIndividualRecord iRec, int toYear) if (iRec == null) return result; try { - var lifeDates = iRec.GetLifeDates(); + var lifeDates = iRec.GetLifeEvents(); result = GetAgeLD(lifeDates, toYear); } catch (Exception ex) { Logger.WriteError("GKUtils.GetAge()", ex); @@ -1258,7 +1258,7 @@ public static int GetAge(GDMIndividualRecord iRec, int toYear) return result; } - public static int GetAgeLD(GDMIndividualRecord.LifeDatesRet lifeDates, int toYear) + public static int GetAgeLD(GDMIndividualRecord.LifeEvents lifeDates, int toYear) { int result = -1; if (lifeDates == null) return result; diff --git a/projects/plugins/GEDmill/GMHelper.cs b/projects/plugins/GEDmill/GMHelper.cs index bf63be5a6..be9347397 100644 --- a/projects/plugins/GEDmill/GMHelper.cs +++ b/projects/plugins/GEDmill/GMHelper.cs @@ -348,7 +348,7 @@ public static string ConstructName(string surname, string firstName) public static string GetLifeDatesStr(GDMIndividualRecord record) { - var lifeDates = record.GetLifeDates(); + var lifeDates = record.GetLifeEvents(); string birthDate = GKUtils.GEDCOMEventToDateStr(lifeDates.BirthEvent, DateFormat.dfYYYY, false); string deathDate = GKUtils.GEDCOMEventToDateStr(lifeDates.DeathEvent, DateFormat.dfYYYY, false); return birthDate + " - " + deathDate; diff --git a/projects/plugins/GEDmill/HTML/CreatorRecordIndividual.cs b/projects/plugins/GEDmill/HTML/CreatorRecordIndividual.cs index 350294b0d..f4c4f3c20 100644 --- a/projects/plugins/GEDmill/HTML/CreatorRecordIndividual.cs +++ b/projects/plugins/GEDmill/HTML/CreatorRecordIndividual.cs @@ -177,7 +177,7 @@ public bool Create(Stats stats, MTTree miniTree) RemoveLoneOccupation(); - var lifeDatesX = fIndiRec.GetLifeDates(); + var lifeDatesX = fIndiRec.GetLifeEvents(); fActualBirthday = (lifeDatesX.BirthEvent == null) ? null : lifeDatesX.BirthEvent.Date; fActualDeathday = (lifeDatesX.DeathEvent == null) ? null : lifeDatesX.DeathEvent.Date; diff --git a/projects/plugins/GEDmill/MainForm.cs b/projects/plugins/GEDmill/MainForm.cs index a76c5aa86..a8543a202 100644 --- a/projects/plugins/GEDmill/MainForm.cs +++ b/projects/plugins/GEDmill/MainForm.cs @@ -1347,7 +1347,7 @@ private void SetIndividualSubItems(ListViewItem lvItem, GDMIndividualRecord ir) string surname, firstName; GMHelper.CapitaliseName(ir.GetPrimaryPersonalName(), out firstName, out surname); - var lifeDatesX = ir.GetLifeDates(); + var lifeDatesX = ir.GetLifeEvents(); var birthDate = (lifeDatesX.BirthEvent == null) ? 0 : lifeDatesX.BirthEvent.Date.GetChronologicalYear(); var deathDate = (lifeDatesX.DeathEvent == null) ? 0 : lifeDatesX.DeathEvent.Date.GetChronologicalYear(); string uref = (ir.HasUserReferences) ? ir.UserReferences[0].StringValue : ""; diff --git a/projects/plugins/GKStdReports/ContemporariesReport.cs b/projects/plugins/GKStdReports/ContemporariesReport.cs index 724d39a4c..d63c459af 100644 --- a/projects/plugins/GKStdReports/ContemporariesReport.cs +++ b/projects/plugins/GKStdReports/ContemporariesReport.cs @@ -47,7 +47,7 @@ public ContemporariesReport(IBaseWindow baseWin, GDMIndividualRecord selectedPer private Range GetIndividualDates(GDMIndividualRecord iRec) { - var dates = iRec.GetLifeDates(); + var dates = iRec.GetLifeEvents(); int yBirth = (dates.BirthEvent == null) ? 0 : dates.BirthEvent.GetChronologicalYear(); int yDeath = (dates.DeathEvent == null) ? 0 : dates.DeathEvent.GetChronologicalYear();