本文整理汇总了PHP中Fisharebest\Webtrees\Date类的典型用法代码示例。如果您正苦于以下问题:PHP Date类的具体用法?PHP Date怎么用?PHP Date使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Date类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isSourced
/**
* Check if a fact has a date and is sourced
* Values:
* - 0, if no date is found for the fact
* - -1, if the date is not precise
* - -2, if the date is precise, but no source is found
* - 1, if the date is precise, and a source is found
* - 2, if the date is precise, a source exists, and is supported by a certificate (requires _ACT usage)
* - 3, if the date is precise, a source exists, and the certificate supporting the fact is within an acceptable range of date
*
* @return int Level of sources
*/
public function isSourced()
{
$isSourced = 0;
$date = $this->fact->getDate();
if ($date->isOK()) {
$isSourced = -1;
if ($date->qual1 == '' && $date->minimumJulianDay() == $date->maximumJulianDay()) {
$isSourced = -2;
$citations = $this->fact->getCitations();
foreach ($citations as $citation) {
$isSourced = max($isSourced, 1);
if (preg_match('/3 _ACT (.*)/', $citation)) {
$isSourced = max($isSourced, 2);
preg_match_all("/4 DATE (.*)/", $citation, $datessource, PREG_SET_ORDER);
foreach ($datessource as $daterec) {
$datesource = new Date($daterec[1]);
if (abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN) {
$isSourced = max($isSourced, 3);
//If this level increases, do not forget to change the constant MAX_IS_SOURCED_LEVEL
}
}
}
}
}
}
return $isSourced;
}
示例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() === 'F') {
return '';
} else {
return (string) Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
}
}
示例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->getSex() === 'M') {
return '';
} else {
$years = Date::getAge($individual->getEstimatedBirthDate(), $this->date(), 0);
if ($years > 15) {
$years -= $years % 5;
}
return (string) $years;
}
}
示例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)
{
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 '';
}
示例5: 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 '';
}
$count = 0;
foreach ($individual->getSpouseFamilies() as $family) {
foreach ($family->getChildren() as $child) {
if ($child->getBirthDate()->isOK() && Date::compare($child->getBirthDate(), $this->date()) < 0 && $child->getBirthDate() != $child->getDeathDate() && (!$child->getDeathDate()->isOK() || Date::compare($child->getDeathDate(), $this->date()) > 0)) {
$count++;
}
}
}
return (string) $count;
}
示例6: 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);
}
}
示例7: 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)
{
$place = $individual->getBirthPlace();
// Did we emigrate or naturalise?
foreach ($individual->getFacts('IMMI|EMIG|NATU', true) as $fact) {
if (Date::compare($fact->getDate(), $this->date()) <= 0) {
$place = $fact->getPlace()->getGedcomName();
}
}
$place = explode(', ', $place);
$place = end($place);
if ($place === 'England' || $place === 'Scotland' || $place === 'Wales') {
return 'British';
} else {
return $place;
}
}
示例8: nameAtCensusDate
/**
* What was an individual's likely name on a given date, allowing
* for marriages and married names.
*
* @param Individual $individual
* @param Date $census_date
*
* @return string[]
*/
protected function nameAtCensusDate(Individual $individual, Date $census_date)
{
$names = $individual->getAllNames();
$name = $names[0];
foreach ($individual->getSpouseFamilies() as $family) {
foreach ($family->getFacts('MARR') as $marriage) {
if ($marriage->getDate()->isOK() && Date::compare($marriage->getDate(), $census_date) < 0) {
$spouse = $family->getSpouse($individual);
foreach ($names as $individual_name) {
foreach ($spouse->getAllNames() as $spouse_name) {
if ($individual_name['type'] === '_MARNM' && $individual_name['surn'] === $spouse_name['surn']) {
return $individual_name;
}
}
}
}
}
}
return $name;
}
示例9: renderContent
//.........这里部分代码省略.........
<a <?php
echo $title . ' ' . $class;
?>
href="<?php
echo $person->getHtmlUrl();
?>
">
<?php
echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']);
?>
</a>
<?php
echo $sex_image . FunctionsPrint::formatSosaNumbers($dperson->getSosaNumbers(), 1, 'smaller');
?>
<br/>
<?php
}
echo $person->getPrimaryParentsNames('parents details1', 'none');
?>
</td>
<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>
<td>
<?php
if ($birth_dates = $person->getAllBirthDates()) {
foreach ($birth_dates as $num => $birth_date) {
if ($num) {
?>
<br/><?php
}
?>
<?php
echo $birth_date->display(true);
}
} else {
$birth_date = new Date('');
if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) {
$birth_date = $person->getEstimatedBirthDate();
echo $birth_date->display(true);
} else {
echo ' ';
}
$birth_dates[0] = new Date('');
}
?>
</td>
<td><?php
echo $birth_date->julianDay();
?>
</td>
<td>
<?php
foreach ($person->getAllBirthPlaces() as $n => $birth_place) {
$tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree());
if ($n) {
?>
<br><?php
示例10: compare
/**
* Compare two dates, so they can be sorted.
*
* return <0 if $a<$b
* return >0 if $b>$a
* return 0 if dates same/overlap
* BEF/AFT sort as the day before/after
*
* @param Date $a
* @param Date $b
*
* @return int
*/
public static function compare(Date $a, Date $b)
{
// Get min/max JD for each date.
switch ($a->qual1) {
case 'BEF':
$amin = $a->minimumJulianDay() - 1;
$amax = $amin;
break;
case 'AFT':
$amax = $a->maximumJulianDay() + 1;
$amin = $amax;
break;
default:
$amin = $a->minimumJulianDay();
$amax = $a->maximumJulianDay();
break;
}
switch ($b->qual1) {
case 'BEF':
$bmin = $b->minimumJulianDay() - 1;
$bmax = $bmin;
break;
case 'AFT':
$bmax = $b->maximumJulianDay() + 1;
$bmin = $bmax;
break;
default:
$bmin = $b->minimumJulianDay();
$bmax = $b->maximumJulianDay();
break;
}
if ($amax < $bmin) {
return -1;
} elseif ($amin > $bmax && $bmax > 0) {
return 1;
} elseif ($amin < $bmin && $amax <= $bmax) {
return -1;
} elseif ($amin > $bmin && $amax >= $bmax && $bmax > 0) {
return 1;
} else {
return 0;
}
}
示例11: 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();
}
示例12: updateDates
/**
* Extract all the dates from the given record and insert them into the database.
*
* @param string $xref
* @param int $ged_id
* @param string $gedrec
*/
public static function updateDates($xref, $ged_id, $gedrec)
{
if (strpos($gedrec, '2 DATE ') && preg_match_all("/\n1 (\\w+).*(?:\n[2-9].*)*(?:\n2 DATE (.+))(?:\n[2-9].*)*/", $gedrec, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$fact = $match[1];
if (($fact == 'FACT' || $fact == 'EVEN') && preg_match("/\n2 TYPE ([A-Z]{3,5})/", $match[0], $tmatch)) {
$fact = $tmatch[1];
}
$date = new Date($match[2]);
Database::prepare("INSERT INTO `##dates` (d_day,d_month,d_mon,d_year,d_julianday1,d_julianday2,d_fact,d_gid,d_file,d_type) VALUES (?,?,?,?,?,?,?,?,?,?)")->execute(array($date->minimumDate()->d, $date->minimumDate()->format('%O'), $date->minimumDate()->m, $date->minimumDate()->y, $date->minimumDate()->minJD, $date->minimumDate()->maxJD, $fact, $xref, $ged_id, $date->minimumDate()->format('%@')));
if ($date->minimumDate() !== $date->maximumDate()) {
Database::prepare("INSERT INTO `##dates` (d_day,d_month,d_mon,d_year,d_julianday1,d_julianday2,d_fact,d_gid,d_file,d_type) VALUES (?,?,?,?,?,?,?,?,?,?)")->execute(array($date->maximumDate()->d, $date->maximumDate()->format('%O'), $date->maximumDate()->m, $date->maximumDate()->y, $date->maximumDate()->minJD, $date->maximumDate()->maxJD, $fact, $xref, $ged_id, $date->maximumDate()->format('%@')));
}
}
}
}
示例13: renderContent
//.........这里部分代码省略.........
?>
<th> </th>
<th></th>
<?php
}
?>
<th><i class="icon-children" title="<?php
echo I18N::translate('Children');
?>
"></i></th>
<th>NCHI</th>
<th>MARR</th>
<th>DEAT</th>
<th>TREE</th>
</tr>
</thead>
<tbody>
<?php
foreach ($this->data->get('sosa_list') as $sosa => $family) {
/** @var \Fisharebest\Webtrees\Family $person */
//PERSO Create decorator for Family
$dfamily = new Family($family);
$husb = $family->getHusband();
if (is_null($husb)) {
$husb = new Individual('H', '0 @H@ INDI', null, $family->getTree());
}
$dhusb = new \MyArtJaub\Webtrees\Individual($husb);
$wife = $family->getWife();
if (is_null($wife)) {
$wife = new Individual('W', '0 @W@ INDI', null, $family->getTree());
}
$dwife = new \MyArtJaub\Webtrees\Individual($wife);
$mdate = $family->getMarriageDate();
if ($family->isPendingAddtion()) {
$class = ' class="new"';
} elseif ($family->isPendingDeletion()) {
$class = ' class="old"';
} else {
$class = '';
}
?>
<tr <?php
echo $class;
?>
>
<td class="transparent"><?php
echo I18N::translate('%1$d/%2$d', $sosa, ($sosa + 1) % 10);
?>
</td>
<td class="transparent"><?php
echo $sosa;
?>
</td>
<!-- HUSBAND -->
<td colspan="2">
<?php
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"';
示例14: foreach
$gedrec .= FunctionsEdit::addNewFact($match);
}
}
$gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref);
if (Filter::postBool('SOUR_INDI')) {
$gedrec = FunctionsEdit::handleUpdates($gedrec);
} else {
$gedrec = FunctionsEdit::updateRest($gedrec);
}
// Create the new child
$new_child = $family->getTree()->createRecord($gedrec);
// Insert new child at the right place
$done = false;
foreach ($family->getFacts('CHIL') as $fact) {
$old_child = $fact->getTarget();
if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) {
// Insert before this child
$family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan);
$done = true;
break;
}
}
if (!$done) {
// Append child at end
$family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan);
}
if (Filter::post('goto') === 'new') {
$controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");');
} else {
$controller->addInlineJavascript('closePopupAndReloadParent();');
}
示例15: eventQuery
/**
* Events
*
* @param string $type
* @param string $direction
* @param string $facts
*
* @return string
*/
private function eventQuery($type, $direction, $facts)
{
$eventTypes = array('BIRT' => I18N::translate('birth'), 'DEAT' => I18N::translate('death'), 'MARR' => I18N::translate('marriage'), 'ADOP' => I18N::translate('adoption'), 'BURI' => I18N::translate('burial'), 'CENS' => I18N::translate('census added'));
$fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
if ($direction != 'ASC') {
$direction = 'DESC';
}
$rows = $this->runSql('' . ' SELECT SQL_CACHE' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " `##dates`" . ' WHERE' . " d_file={$this->tree->getTreeId()} AND" . " d_gid<>'HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1<>0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type LIMIT 1");
if (!isset($rows[0])) {
return '';
}
$row = $rows[0];
$record = GedcomRecord::getInstance($row['id'], $this->tree);
switch ($type) {
default:
case 'full':
if ($record->canShow()) {
$result = $record->formatList('span', false, $record->getFullName());
} else {
$result = I18N::translate('This information is private and cannot be shown.');
}
break;
case 'year':
$date = new Date($row['type'] . ' ' . $row['year']);
$result = $date->display();
break;
case 'type':
if (isset($eventTypes[$row['fact']])) {
$result = $eventTypes[$row['fact']];
} else {
$result = GedcomTag::getLabel($row['fact']);
}
break;
case 'name':
$result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>";
break;
case 'place':
$fact = $record->getFirstFact($row['fact']);
if ($fact) {
$result = FunctionsPrint::formatFactPlace($fact, true, true, true);
} else {
$result = I18N::translate('Private');
}
break;
}
return $result;
}