本文整理汇总了PHP中Fisharebest\Webtrees\Date::getAge方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::getAge方法的具体用法?PHP Date::getAge怎么用?PHP Date::getAge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Date
的用法示例。
在下文中一共展示了Date::getAge方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate the likely value of this census column, based on available information.
*
* @param Individual $individual
* @param Individual|null $head
*
* @return string
*/
public function generate(Individual $individual, Individual $head = null)
{
if ($individual->getSex() === 'F') {
return '';
} else {
return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
}
}
示例2: generate
/**
* Generate the likely value of this census column, based on available information.
*
* @param Individual $individual
* @param Individual|null $head
*
* @return string
*/
public function generate(Individual $individual, Individual $head = null)
{
if ($individual->getSex() === 'M') {
return '';
} else {
$years = Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
if ($years > 15) {
$years -= $years % 5;
}
return (string) $years;
}
}
示例3: generate
/**
* Generate the likely value of this census column, based on available information.
*
* @param Individual $individual
* @param Individual|null $head
*
* @return string
*/
public function generate(Individual $individual, Individual $head = null)
{
if ($individual->getBirthDate()->isOK()) {
foreach ($individual->getSpouseFamilies() as $family) {
foreach ($family->getFacts('MARR', true) as $fact) {
if ($fact->getDate()->isOK()) {
return Date::getAge($individual->getBirthDate(), $fact->getDate(), 0);
}
}
}
}
return '';
}
示例4: generate
/**
* Generate the likely value of this census column, based on available information.
*
* @param Individual $individual
* @param Individual|null $head
*
* @return string
*/
public function generate(Individual $individual, Individual $head = null)
{
$marriage_date = null;
foreach ($individual->getSpouseFamilies() as $family) {
foreach ($family->getFacts('MARR', true) as $fact) {
if ($fact->getDate()->isOK() && Date::compare($fact->getDate(), $this->date()) <= 0) {
$marriage_date = $fact->getDate();
}
}
}
if ($marriage_date === null) {
return '';
} else {
return (string) Date::getAge($marriage_date, $this->date(), 0);
}
}
示例5: renderContent
//.........这里部分代码省略.........
href="<?php
echo $husb->getHtmlUrl();
?>
">
<?php
echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']);
?>
</a>
<?php
echo $sex_image . FunctionsPrint::formatSosaNumbers($dhusb->getSosaNumbers(), 1, 'smaller');
?>
<br/>
<?php
}
echo $husb->getPrimaryParentsNames('parents details1', 'none');
?>
</td>
<!-- Dummy column to match colspan in header -->
<td style="display:none;"></td>
<td>
<?php
echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn));
?>
</td>
<td>
<?php
echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn));
?>
</td>
<?php
$hdate = $husb->getBirthDate();
?>
<td><?php
Date::getAge($hdate, $mdate, 2);
?>
</td>
<td><?php
Date::getAge($hdate, $mdate, 1);
?>
</td>
<!-- WIFE -->
<td colspan="2">
<?php
foreach ($wife->getAllNames() as $num => $name) {
if ($name['type'] == 'NAME') {
$title = '';
} else {
$title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $wife)) . '"';
}
if ($num == $wife->getPrimaryName()) {
$class = ' class="name2"';
$sex_image = $wife->getSexImage();
list($surn, $givn) = explode(',', $name['sort']);
} else {
$class = '';
$sex_image = '';
}
?>
<a <?php
echo $title . ' ' . $class;
?>
href="<?php
echo $wife->getHtmlUrl();
?>
">
<?php
示例6: formatParentsAges
/**
* Format age of parents in HTML
*
* @param Individual $person child
* @param Date $birth_date
*
* @return string HTML
*/
public static function formatParentsAges(Individual $person, Date $birth_date)
{
$html = '';
$families = $person->getChildFamilies();
// Multiple sets of parents (e.g. adoption) cause complications, so ignore.
if ($birth_date->isOK() && count($families) == 1) {
$family = current($families);
foreach ($family->getSpouses() as $parent) {
if ($parent->getBirthDate()->isOK()) {
$sex = $parent->getSexImage();
$age = Date::getAge($parent->getBirthDate(), $birth_date, 2);
$deatdate = $parent->getDeathDate();
switch ($parent->getSex()) {
case 'F':
// Highlight mothers who die in childbirth or shortly afterwards
if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay() + 90) {
$html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
} else {
$html .= ' <span title="' . I18N::translate('Mother’s age') . '">' . $sex . $age . '</span>';
}
break;
case 'M':
// Highlight fathers who die before the birth
if ($deatdate->isOK() && $deatdate->maximumJulianDay() < $birth_date->minimumJulianDay()) {
$html .= ' <span title="' . GedcomTag::getLabel('_DEAT_PARE', $parent) . '" class="parentdeath">' . $sex . $age . '</span>';
} else {
$html .= ' <span title="' . I18N::translate('Father’s age') . '">' . $sex . $age . '</span>';
}
break;
default:
$html .= ' <span title="' . I18N::translate('Parent’s age') . '">' . $sex . $age . '</span>';
break;
}
}
}
if ($html) {
$html = '<span class="age">' . $html . '</span>';
}
}
return $html;
}
示例7: renderContent
//.........这里部分代码省略.........
?>
<td>
<?php
if ($death_dates = $person->getAllDeathDates()) {
foreach ($death_dates as $num => $death_date) {
if ($num) {
?>
<br/><?php
}
?>
<?php
echo $death_date->display(true);
}
} else {
$death_date = $person->getEstimatedDeathDate();
if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES') && $death_date->minimumJulianDay() < WT_CLIENT_JD) {
echo $death_date->display(true);
} elseif ($person->isDead()) {
echo I18N::translate('yes');
$death_date = new Date('');
} else {
echo ' ';
$death_date = new Date('');
}
$death_dates[0] = new Date('');
}
?>
</td>
<td><?php
echo $death_date->julianDay();
?>
</td>
<td><?php
echo Date::getAge($birth_dates[0], $death_dates[0], 2);
?>
</td>
<td><?php
echo Date::getAge($birth_dates[0], $death_dates[0], 1);
?>
</td>
<td>
<?php
foreach ($person->getAllDeathPlaces() as $n => $death_place) {
$tmp = new Place($death_place, $person->getTree());
if ($n) {
?>
<br><?php
}
?>
<a href="'<?php
echo $tmp->getURL();
?>
" title="<?php
echo strip_tags($tmp->getFullName());
?>
">
<?php
echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName());
?>
</a>
<?php
}
?>
</td>
<?php
if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
示例8: renderFamSosaListIndi
//.........这里部分代码省略.........
/* 11-SURN,GIVN */ { type: "unicode", visible: false},
/* 12-Wife Age */ { dataSort: 13, class: "center"},
/* 13-AGE */ { type: "num", visible: false},
/* 14-Marr Date */ { dataSort: 15, class: "center"},
/* 15-MARR:DATE */ { visible: false},
/* 16-Marr Plac */ { type: "unicode", class: "center"},
/* 17-Marr Sour */ { dataSort : 18, class: "center", visible: ' . (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME) ? 'true' : 'false') . ' },
/* 18-Sort Sour */ { visible: false},
/* 19-Children */ { dataSort: 20, class: "center"},
/* 20-NCHI */ { type: "num", visible: false},
/* 21-MARR */ { visible: false},
/* 22-DEAT */ { visible: false},
/* 23-TREE */ { visible: false}
],
sorting: [[0, "asc"]],
displayLength: 16,
pagingType: "full_numbers"
});
jQuery("#' . $table_id . '")
/* Hide/show parents */
.on("click", ".btn-toggle-parents", function() {
jQuery(this).toggleClass("ui-state-active");
jQuery(".parents", jQuery(this).closest("table").DataTable().rows().nodes()).slideToggle();
})
/* Hide/show statistics */
.on("click", ".btn-toggle-statistics", function() {
jQuery(this).toggleClass("ui-state-active");
jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle();
})
/* Filter buttons in table header */
.on("click", "button[data-filter-column]", function() {
var btn = $(this);
// De-activate the other buttons in this button group
btn.siblings().removeClass("ui-state-active");
// Apply (or clear) this filter
var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
if (btn.hasClass("ui-state-active")) {
btn.removeClass("ui-state-active");
col.search("").draw();
} else {
btn.addClass("ui-state-active");
col.search(btn.data("filter-value")).draw();
}
});
jQuery("#sosa-fam-list").css("visibility", "visible");
jQuery("#btn-toggle-statistics-' . $table_id . '").click();
');
$stats = new Stats($WT_TREE);
$max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1;
//-- init chart data
$marr_by_age = array();
for ($age = 0; $age <= $max_age; $age++) {
$marr_by_age[$age] = '';
}
$birt_by_decade = array();
$marr_by_decade = array();
for ($year = 1550; $year < 2030; $year += 10) {
$birt_by_decade[$year] = '';
$marr_by_decade[$year] = '';
}
foreach ($listFamSosa as $sosa => $fid) {
$sfamily = Family::getInstance($fid, $WT_TREE);
if (!$sfamily || !$sfamily->canShow()) {
unset($sfamily[$sosa]);
continue;
}
$mdate = $sfamily->getMarriageDate();
if (($husb = $sfamily->getHusband()) && ($hdate = $husb->getBirthDate()) && $hdate->isOK() && $mdate->isOK()) {
if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
}
$hage = Date::getAge($hdate, $mdate, 0);
if ($hage >= 0 && $hage <= $max_age) {
$marr_by_age[$hage] .= $husb->getSex();
}
}
if (($wife = $sfamily->getWife()) && ($wdate = $wife->getBirthDate()) && $wdate->isOK() && $mdate->isOK()) {
if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
$birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
}
$wage = Date::getAge($wdate, $mdate, 0);
if ($wage >= 0 && $wage <= $max_age) {
$marr_by_age[$wage] .= $wife->getSex();
}
}
if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
$marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
}
$listFamSosa[$sosa] = $sfamily;
}
$this->view_bag->set('sosa_list', $listFamSosa);
$this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth')));
$this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage')));
$this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage')));
}
ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render();
}
示例9: printLifespan
/**
* Print the lifespan of this person
*
* @param type $person
* @param type $is_spouse
* @return string
*/
private function printLifespan($person, $is_spouse = false)
{
$html = '';
$birthdate = $person->getBirthDate();
$deathdate = $person->getDeathdate();
$ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($birthdate, $deathdate), false);
$birthdata = false;
if ($birthdate->isOK() || $person->getBirthPlace() != '') {
$birthdata = true;
$bapm = $person->getFirstFact('BAPM');
$chr = $person->getFirstFact('CHR');
$birt = $person->getFirstFact('BIRT');
if ($birt) {
$html .= $this->printBirthText($person, 'BIRT', $is_spouse);
$html .= $this->printDate($birt);
} else {
if ($bapm || $chr) {
$html .= $this->printBirthText($person, 'BAPM', $is_spouse);
$html .= $bapm ? $this->printDate($bapm) : $this->printDate($chr);
}
}
if ($person->getBirthPlace() != '') {
$html .= $this->printPlace($person->getBirthPlace(), $person->getTree());
}
}
$deathdata = false;
if ($deathdate->isOK() || $person->getDeathPlace() != '') {
$deathdata = true;
if ($birthdata) {
$html .= ' ' . I18N::translate('and ');
$person->getSex() == 'F' ? $html .= I18N::translateContext('FEMALE', 'died') : ($html .= I18N::translateContext('MALE', 'died'));
} else {
$person->getSex() == 'F' ? $html .= '. ' . I18N::translate('She died') : ($html .= '. ' . I18N::translate('He died'));
}
$deat = $person->getFirstFact('DEAT');
if ($deat) {
$html .= $this->printDate($deat);
}
if ($person->getDeathPlace() != '') {
$html .= $this->printPlace($person->getDeathPlace(), $person->getTree());
}
if ($birthdate->isOK() && $deathdate->isOK() && $this->isDateDMY($birt) && $this->isDateDMY($deat)) {
if (Date::getAge($birthdate, $deathdate, 0) < 2) {
$html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath);
} else {
$html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath);
}
}
}
return $html;
}
示例10: isChild
/**
* Is the individual a child.
*
* @param Individual $individual
*
* @return bool
*/
private function isChild(Individual $individual)
{
$age = (int) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
return $age < $this->age_adult;
}
示例11: familyTable
//.........这里部分代码省略.........
$title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $husb)) . '"';
}
if ($num == $husb->getPrimaryName()) {
$class = ' class="name2"';
$sex_image = $husb->getSexImage();
list($surn, $givn) = explode(',', $name['sort']);
} else {
$class = '';
$sex_image = '';
}
// Only show married names if they are the name we are filtering by.
if ($name['type'] != '_MARNM' || $num == $husb->getPrimaryName()) {
$html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . FunctionsPrint::highlightSearchHits($name['full']) . '</a>' . $sex_image . '<br>';
}
}
// Husband parents
$html .= $husb->getPrimaryParentsNames('parents details1', 'none');
$html .= '</td>';
// Dummy column to match colspan in header
$html .= '<td style="display:none;"></td>';
//-- Husb GIVN
// Use "AAAA" as a separator (instead of ",") as Javascript.localeCompare() ignores
// punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it.
// Similarly, @N.N. would sort as NN.
$html .= '<td>' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . '</td>';
$html .= '<td>' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . '</td>';
$mdate = $family->getMarriageDate();
//-- Husband age
$hdate = $husb->getBirthDate();
if ($hdate->isOK() && $mdate->isOK()) {
if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) {
$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
}
$hage = Date::getAge($hdate, $mdate, 0);
if ($hage >= 0 && $hage <= $max_age) {
$marr_by_age[$hage] .= $husb->getSex();
}
}
$html .= '<td>' . Date::getAge($hdate, $mdate, 2) . '</td><td>' . Date::getAge($hdate, $mdate, 1) . '</td>';
//-- Wife name(s)
$html .= '<td colspan="2">';
foreach ($wife->getAllNames() as $num => $name) {
if ($name['type'] == 'NAME') {
$title = '';
} else {
$title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $wife)) . '"';
}
if ($num == $wife->getPrimaryName()) {
$class = ' class="name2"';
$sex_image = $wife->getSexImage();
list($surn, $givn) = explode(',', $name['sort']);
} else {
$class = '';
$sex_image = '';
}
// Only show married names if they are the name we are filtering by.
if ($name['type'] != '_MARNM' || $num == $wife->getPrimaryName()) {
$html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . FunctionsPrint::highlightSearchHits($name['full']) . '</a>' . $sex_image . '<br>';
}
}
// Wife parents
$html .= $wife->getPrimaryParentsNames('parents details1', 'none');
$html .= '</td>';
// Dummy column to match colspan in header
$html .= '<td style="display:none;"></td>';
//-- Wife GIVN
示例12: printAgeOfDeath
/**
* Print the age at death/bury
* @param type $bfact
* @param type $dfact
* @return string
*/
private function printAgeOfDeath($bfact, $dfact)
{
$bdate = $bfact->getDate();
$ddate = $dfact->getDate();
$html = '';
if ($bdate->isOK() && $ddate->isOK() && $this->isDateDMY($bfact) && $this->isDateDMY($dfact)) {
$ageOfdeath = FunctionsDate::getAgeAtEvent(Date::GetAgeGedcom($bdate, $ddate), false);
if (Date::getAge($bdate, $ddate, 0) < 2) {
$html .= ' ' . I18N::translateContext('age in days/months', 'at the age of %s', $ageOfdeath);
} else {
$html .= ' ' . I18N::translateContext('age in years', 'at the age of %s', $ageOfdeath);
}
}
return $html;
}
示例13: familyTable
//.........这里部分代码省略.........
// Extract Given names and Surnames for sorting
list($surn_givn, $givn_surn) = self::sortableNames($husb);
$html .= '<td colspan="2" data-sort="' . Filter::escapeHtml($givn_surn) . '">';
foreach ($husb->getAllNames() as $num => $name) {
if ($name['type'] == 'NAME') {
$title = '';
} else {
$title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $husb)) . '"';
}
if ($num == $husb->getPrimaryName()) {
$class = ' class="name2"';
$sex_image = $husb->getSexImage();
} else {
$class = '';
$sex_image = '';
}
// Only show married names if they are the name we are filtering by.
if ($name['type'] != '_MARNM' || $num == $husb->getPrimaryName()) {
$html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . FunctionsPrint::highlightSearchHits($name['full']) . '</a>' . $sex_image . '<br>';
}
}
// Husband parents
$html .= $husb->getPrimaryParentsNames('parents details1', 'none');
$html .= '</td>';
// Hidden column for sortable name
$html .= '<td hidden data-sort="' . Filter::escapeHtml($surn_givn) . '"></td>';
// Husband age
$mdate = $family->getMarriageDate();
$hdate = $husb->getBirthDate();
if ($hdate->isOK() && $mdate->isOK()) {
if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) {
$birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
}
$hage = Date::getAge($hdate, $mdate, 0);
if ($hage >= 0 && $hage <= $max_age) {
$marr_by_age[$hage] .= $husb->getSex();
}
}
$html .= '<td class="center" data=-sort="' . Date::getAge($hdate, $mdate, 1) . '">' . Date::getAge($hdate, $mdate, 2) . '</td>';
// Wife name(s)
// Extract Given names and Surnames for sorting
list($surn_givn, $givn_surn) = self::sortableNames($wife);
$html .= '<td colspan="2" data-sort="' . Filter::escapeHtml($givn_surn) . '">';
foreach ($wife->getAllNames() as $num => $name) {
if ($name['type'] == 'NAME') {
$title = '';
} else {
$title = 'title="' . strip_tags(GedcomTag::getLabel($name['type'], $wife)) . '"';
}
if ($num == $wife->getPrimaryName()) {
$class = ' class="name2"';
$sex_image = $wife->getSexImage();
} else {
$class = '';
$sex_image = '';
}
// Only show married names if they are the name we are filtering by.
if ($name['type'] != '_MARNM' || $num == $wife->getPrimaryName()) {
$html .= '<a ' . $title . ' href="' . $family->getHtmlUrl() . '"' . $class . '>' . FunctionsPrint::highlightSearchHits($name['full']) . '</a>' . $sex_image . '<br>';
}
}
// Wife parents
$html .= $wife->getPrimaryParentsNames('parents details1', 'none');
$html .= '</td>';
// Hidden column for sortable name
$html .= '<td hidden data-sort="' . Filter::escapeHtml($surn_givn) . '"></td>';