Ejemplo n.º 1
0
        public Age(Individual ind, FactDate when)
            : this()
        {
            if (when.IsAfter(ind.DeathDate))
            {
                when = ind.DeathDate;
            }

            //Logger.Debug($"Calculating Age for {ind.Name} on {when}");
            //Logger.Debug($"Min age: birth enddate: {ind.BirthDate.EndDate} to startdate: {when.StartDate}");
            //Logger.Debug($"Max age: birth startdate: {ind.BirthDate.StartDate} to enddate: {when.EndDate}");

            MinAge = GetAge(ind.BirthDate.EndDate, when.StartDate);
            MaxAge = GetAge(ind.BirthDate.StartDate, when.EndDate);

            //Logger.Debug($"Calculated minage: {MinAge} calculated maxage: {MaxAge}");
            if (MinAge == FactDate.MINYEARS)
            {
                _age = (MaxAge == FactDate.MAXYEARS) ? "Unknown" : MaxAge == 0 ? "< 1" : $"<= {MaxAge}";
            }
            else if (MaxAge < FactDate.MAXYEARS)
            {
                _age = MinAge == MaxAge ? $"{MinAge}" : $"{MinAge} to {MaxAge}";
            }
            else
            {
                _age = $">= {MinAge}"; // if age over maximum return maximum
            }
        }
Ejemplo n.º 2
0
 public Age(Individual ind, FactDate when)
     : this()
 {
     if (when.IsAfter(ind.DeathDate))
     {
         when = ind.DeathDate;
     }
     log.Debug("Calculating Age for " + ind.Name + " on " + when.ToString());
     log.Debug("Min age: birth enddate:" + ind.BirthDate.EndDate + " to startdate:" + when.StartDate);
     log.Debug("Max age: birth startdate:" + ind.BirthDate.StartDate + " to enddate:" + when.EndDate);
     MinAge = GetAge(ind.BirthDate.EndDate, when.StartDate);
     MaxAge = GetAge(ind.BirthDate.StartDate, when.EndDate);
     log.Debug("Calculated minage:" + MinAge + " calculated maxage:" + MaxAge);
     if (MinAge == FactDate.MINYEARS)
     {
         if (MaxAge == FactDate.MAXYEARS)
         {
             age = "Unknown";
         }
         else
         {
             age = MaxAge == 0 ? "< 1" : "<=" + MaxAge;
         }
     }
     else if (MaxAge < FactDate.MAXYEARS)
     {
         age = MinAge == MaxAge?MinAge.ToString() : MinAge + " to " + MaxAge;
     }
     else
     {
         // if age over maximum return maximum
         age = ">=" + MinAge;
     }
 }