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->MinJD()) { global $MAX_ALIVE_AGE; $min[] = $tmp->MinJD() - $MAX_ALIVE_AGE * 365; $max[] = $tmp->MaxJD(); } foreach ($this->getChildFamilies() as $family) { $tmp = $family->getMarriageDate(); if (is_object($tmp) && $tmp->MinJD()) { $min[] = $tmp->MaxJD() - 365 * 1; $max[] = $tmp->MinJD() + 365 * 30; } if ($parent = $family->getHusband()) { $tmp = $parent->getBirthDate(); if (is_object($tmp) && $tmp->MinJD()) { $min[] = $tmp->MaxJD() + 365 * 15; $max[] = $tmp->MinJD() + 365 * 65; } } if ($parent = $family->getWife()) { $tmp = $parent->getBirthDate(); if (is_object($tmp) && $tmp->MinJD()) { $min[] = $tmp->MaxJD() + 365 * 15; $max[] = $tmp->MinJD() + 365 * 45; } } foreach ($family->getChildren() as $child) { $tmp = $child->getBirthDate(); if ($tmp->MinJD()) { $min[] = $tmp->MaxJD() - 365 * 30; $max[] = $tmp->MinJD() + 365 * 30; } } } foreach ($this->getSpouseFamilies() as $family) { $tmp = $family->getMarriageDate(); if (is_object($tmp) && $tmp->MinJD()) { $min[] = $tmp->MaxJD() - 365 * 45; $max[] = $tmp->MinJD() - 365 * 15; } $spouse = $family->getSpouse($this); if ($spouse) { $tmp = $spouse->getBirthDate(); if ($tmp->MinJD()) { $min[] = $tmp->MaxJD() - 365 * 25; $max[] = $tmp->MinJD() + 365 * 25; } } foreach ($family->getChildren() as $child) { $tmp = $child->getBirthDate(); if ($tmp->MinJD()) { $min[] = $tmp->MaxJD() - 365 * ($this->getSex() == 'F' ? 45 : 65); $max[] = $tmp->MinJD() - 365 * 15; } } } if ($min && $max) { list($y) = WT_Date_Gregorian::JDtoYMD((int) ((max($min) + min($max)) / 2)); $this->_getEstimatedBirthDate = new WT_Date("EST {$y}"); } else { $this->_getEstimatedBirthDate = new WT_Date(''); // always return a date object } } } return $this->_getEstimatedBirthDate; }
function gregorianYear() { if ($this->isOK()) { list($y) = WT_Date_Gregorian::JDtoYMD($this->JD()); return $y; } else { return 0; } }