Example #1
0
		internal string ToRelativeProfileText(JulianDay date)
		{
			ProfileCode profileCode = base.Value;
			if (profileCode < 0 || profileCode > Max)
				profileCode = 0;
			JulianDay birthDate = 0;
			double lifeExpectancy = 0;
			Profile profile = App.Model.ProfileHolder.Profile;
			if (profileCode == ProfileCode.MeBirth)
			{
				birthDate = profile.Me.BirthDate;
				lifeExpectancy = profile.Me.LifeExpectancy;
			}
			else
			if (profileCode == ProfileCode.SpouseBirth)
			{
				if (profile.IncludeSpouse)
				{
					birthDate = profile.Spouse.BirthDate;
					lifeExpectancy = profile.Spouse.LifeExpectancy;
				}
			}
			else
			if (profileCode >= ProfileCode.DependentMin && profileCode <= ProfileCode.DependentMax)
			{
				int dependent = (profileCode - ProfileCode.DependentMin) / ProfileCode.Range;
				Person person = (profile.IncludeDependents && dependent < profile.Dependents.Count ? profile.Dependents[dependent] : null);
				if (person != null)
				{
					birthDate = person.BirthDate;
					lifeExpectancy = person.LifeExpectancy;
				}
			}

			if (birthDate == 0)
				return null;

			int daysAlive = (int)date - (int)birthDate;
			if (daysAlive < 0)
				return null;

//j			if (daysAlive > JulianDate.YearsToDays(lifeExpectancy))
//j				return null;

			double age = JulianDate.DaysToYears((uint)daysAlive);
			profileCode += (int)age;

			ProfileDate pjd = new ProfileDate() { ProfileCode = profileCode, JulianDay = date };
			return pjd.GetTextFromProfile();
		}