Пример #1
0
 /**
  * Generate an estimate for the date of birth, based on dates of parents/children/spouses
  *
  * @return Date
  */
 public function getEstimatedBirthDate()
 {
     if (is_null($this->_getEstimatedBirthDate)) {
         foreach ($this->getAllBirthDates() as $date) {
             if ($date->isOK()) {
                 $this->_getEstimatedBirthDate = $date;
                 break;
             }
         }
         if (is_null($this->_getEstimatedBirthDate)) {
             $min = array();
             $max = array();
             $tmp = $this->getDeathDate();
             if ($tmp->isOK()) {
                 $min[] = $tmp->minimumJulianDay() - $this->tree->getPreference('MAX_ALIVE_AGE') * 365;
                 $max[] = $tmp->maximumJulianDay();
             }
             foreach ($this->getChildFamilies() as $family) {
                 $tmp = $family->getMarriageDate();
                 if ($tmp->isOK()) {
                     $min[] = $tmp->maximumJulianDay() - 365 * 1;
                     $max[] = $tmp->minimumJulianDay() + 365 * 30;
                 }
                 if ($parent = $family->getHusband()) {
                     $tmp = $parent->getBirthDate();
                     if ($tmp->isOK()) {
                         $min[] = $tmp->maximumJulianDay() + 365 * 15;
                         $max[] = $tmp->minimumJulianDay() + 365 * 65;
                     }
                 }
                 if ($parent = $family->getWife()) {
                     $tmp = $parent->getBirthDate();
                     if ($tmp->isOK()) {
                         $min[] = $tmp->maximumJulianDay() + 365 * 15;
                         $max[] = $tmp->minimumJulianDay() + 365 * 45;
                     }
                 }
                 foreach ($family->getChildren() as $child) {
                     $tmp = $child->getBirthDate();
                     if ($tmp->isOK()) {
                         $min[] = $tmp->maximumJulianDay() - 365 * 30;
                         $max[] = $tmp->minimumJulianDay() + 365 * 30;
                     }
                 }
             }
             foreach ($this->getSpouseFamilies() as $family) {
                 $tmp = $family->getMarriageDate();
                 if ($tmp->isOK()) {
                     $min[] = $tmp->maximumJulianDay() - 365 * 45;
                     $max[] = $tmp->minimumJulianDay() - 365 * 15;
                 }
                 $spouse = $family->getSpouse($this);
                 if ($spouse) {
                     $tmp = $spouse->getBirthDate();
                     if ($tmp->isOK()) {
                         $min[] = $tmp->maximumJulianDay() - 365 * 25;
                         $max[] = $tmp->minimumJulianDay() + 365 * 25;
                     }
                 }
                 foreach ($family->getChildren() as $child) {
                     $tmp = $child->getBirthDate();
                     if ($tmp->isOK()) {
                         $min[] = $tmp->maximumJulianDay() - 365 * ($this->getSex() == 'F' ? 45 : 65);
                         $max[] = $tmp->minimumJulianDay() - 365 * 15;
                     }
                 }
             }
             if ($min && $max) {
                 $gregorian_calendar = new GregorianCalendar();
                 list($year) = $gregorian_calendar->jdToYmd((int) ((max($min) + min($max)) / 2));
                 $this->_getEstimatedBirthDate = new Date('EST ' . $year);
             } else {
                 $this->_getEstimatedBirthDate = new Date('');
                 // always return a date object
             }
         }
     }
     return $this->_getEstimatedBirthDate;
 }
Пример #2
0
 /**
  * Calculate the gregorian year for a date. This should NOT be used internally
  * within WT - we should keep the code "calendar neutral" to allow support for
  * jewish/arabic users. This is only for interfacing with external entities,
  * such as the ancestry.com search interface or the dated fact icons.
  *
  * @return int
  */
 public function gregorianYear()
 {
     if ($this->isOK()) {
         $gregorian_calendar = new GregorianCalendar();
         list($year) = $gregorian_calendar->jdToYmd($this->julianDay());
         return $year;
     } else {
         return 0;
     }
 }