本文整理汇总了PHP中Fisharebest\Webtrees\Date::compare方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::compare方法的具体用法?PHP Date::compare怎么用?PHP Date::compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Date
的用法示例。
在下文中一共展示了Date::compare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 '';
}
$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;
}
示例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)
{
$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);
}
}
示例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)
{
$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;
}
}
示例4: 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;
}
示例5: 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();');
}
示例6: checkFact
/**
* Function checkFact
*
* Does this fact meet the search criteria?
*
* @todo This function is public to support the PHP5.3 closure workaround.
*
* @param Fact $fact
*
* @return bool
*/
public function checkFact(Fact $fact)
{
$valid = !in_array($fact->getTag(), $this->nonfacts);
if ($valid && $this->place_obj) {
$valid = stripos($fact->getPlace()->getGedcomName(), $this->place_obj->getGedcomName()) !== false;
}
if ($valid && $this->startDate) {
if ($this->strictDate && $this->calendar !== $this->defaultCalendar) {
$valid = stripos($fact->getAttribute('DATE'), $this->calendar) !== false;
}
if ($valid) {
$date = $fact->getDate();
$valid = $date->isOK() && Date::compare($date, $this->startDate) >= 0 && Date::compare($date, $this->endDate) <= 0;
}
}
return $valid;
}
示例7: renderContent
//.........这里部分代码省略.........
echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName());
?>
</a>
<?php
}
?>
</td>
<?php
if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) {
$isDSourced = $dperson->isDeathSourced();
?>
<td><?php
echo FunctionsPrint::formatIsSourcedIcon('E', $isDSourced, 'DEAT', 1, 'medium');
?>
</td>
<td><?php
echo $isDSourced;
?>
</td>
<?php
} else {
?>
<td> </td>
<td></td>
<?php
}
?>
<td><?php
echo $person->getSex();
?>
</td>
<td>
<?php
if (!$person->canShow() || Date::compare($birth_date, new Date(date('Y') - 100)) > 0) {
echo 'Y100';
} else {
echo 'YES';
}
?>
</td>
<td>
<?php
if (Date::compare($death_dates[0], new Date(date('Y') - 100)) > 0) {
echo 'Y100';
} elseif ($death_dates[0]->minimumJulianDay() || $person->isDead()) {
echo 'YES';
} else {
echo 'N';
}
?>
</td>
<td>
<?php
if (!$person->getChildFamilies()) {
echo 'R';
} elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) {
echo 'L';
} else {
echo ' ';
}
?>
</td>
</tr>
<?php
}
?>
示例8: compareDeathDate
/**
* Static helper function to sort an array of people by death date
*
* @param Individual $x
* @param Individual $y
*
* @return int
*/
public static function compareDeathDate(Individual $x, Individual $y)
{
return Date::compare($x->getEstimatedDeathDate(), $y->getEstimatedDeathDate());
}
示例9: foreach
);'>
<?php
echo $gparent->getFullName();
?>
</a>
</td>
<tr> <?php
}
// Spouse Children
foreach ($family->getChildren() as $child) {
// Get Spouse child’s marriage status
$married = '';
$marrdate = '';
foreach ($child->getSpouseFamilies() as $childfamily) {
$marrdate = $childfamily->getMarriageDate();
$married = Date::compare($censdate, $marrdate);
}
// Get Child’s Children
$chBLDarray = array();
foreach ($child->getSpouseFamilies() as $childfamily) {
$chchildren = $childfamily->getChildren();
foreach ($chchildren as $chchild) {
$chnam = $chchild->getAllNames();
$chfulln = strip_tags($chnam[0]['full']);
// Child’s Full Name// Child’s Full Name
$chdob = $chchild->getBirthDate()->julianDay();
// Child’s Date of Birth (Julian)
$chdod = $chchild->getDeathDate()->julianDay();
// Child’s Date of Death (Julian)
$chBLD = $chfulln . ', ' . $chdob . ', ' . $chdod;
array_push($chBLDarray, $chBLD);
示例10: historicalFacts
/**
* Get any historical events.
*
* @param Individual $person
*
* @return Fact[]
*/
private static function historicalFacts(Individual $person)
{
$SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
$facts = array();
if ($SHOW_RELATIVES_EVENTS) {
// Only include events between birth and death
$birt_date = $person->getEstimatedBirthDate();
$deat_date = $person->getEstimatedDeathDate();
if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
$histo = array();
require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
foreach ($histo as $hist) {
// Earlier versions of the WIKI encouraged people to use HTML entities,
// rather than UTF8 encoding.
$hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
$fact = new Fact($hist, $person, 'histo');
$sdate = $fact->getDate();
if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) {
$facts[] = $fact;
}
}
}
}
return $facts;
}
示例11: listStartHandler
//.........这里部分代码省略.........
}
}
}
}
}
//-- apply other filters to the list that could not be added to the search string
if ($filters) {
foreach ($this->list as $key => $record) {
foreach ($filters as $filter) {
if (!preg_match("/" . $filter . "/i", $record->privatizeGedcom(Auth::accessLevel($WT_TREE)))) {
unset($this->list[$key]);
break;
}
}
}
}
if ($filters2) {
$mylist = array();
foreach ($this->list as $indi) {
$key = $indi->getXref();
$grec = $indi->privatizeGedcom(Auth::accessLevel($WT_TREE));
$keep = true;
foreach ($filters2 as $filter) {
if ($keep) {
$tag = $filter['tag'];
$expr = $filter['expr'];
$val = $filter['val'];
if ($val == "''") {
$val = "";
}
$tags = explode(":", $tag);
$t = end($tags);
$v = $this->getGedcomValue($tag, 1, $grec);
//-- check for EMAIL and _EMAIL (silly double gedcom standard :P)
if ($t == "EMAIL" && empty($v)) {
$tag = str_replace("EMAIL", "_EMAIL", $tag);
$tags = explode(":", $tag);
$t = end($tags);
$v = Functions::getSubRecord(1, $tag, $grec);
}
switch ($expr) {
case "GTE":
if ($t == "DATE") {
$date1 = new Date($v);
$date2 = new Date($val);
$keep = Date::compare($date1, $date2) >= 0;
} elseif ($val >= $v) {
$keep = true;
}
break;
case "LTE":
if ($t == "DATE") {
$date1 = new Date($v);
$date2 = new Date($val);
$keep = Date::compare($date1, $date2) <= 0;
} elseif ($val >= $v) {
$keep = true;
}
break;
default:
if ($v == $val) {
$keep = true;
} else {
$keep = false;
}
break;
}
}
}
if ($keep) {
$mylist[$key] = $indi;
}
}
$this->list = $mylist;
}
switch ($sortby) {
case 'NAME':
uasort($this->list, '\\Fisharebest\\Webtrees\\GedcomRecord::compare');
break;
case 'CHAN':
uasort($this->list, function (GedcomRecord $x, GedcomRecord $y) {
return $y->lastChangeTimestamp(true) - $x->lastChangeTimestamp(true);
});
break;
case 'BIRT:DATE':
uasort($this->list, '\\Fisharebest\\Webtrees\\Individual::compareBirthDate');
break;
case 'DEAT:DATE':
uasort($this->list, '\\Fisharebest\\Webtrees\\Individual::compareDeathDate');
break;
case 'MARR:DATE':
uasort($this->list, '\\Fisharebest\\Webtrees\\Family::compareMarrDate');
break;
default:
// unsorted or already sorted by SQL
break;
}
array_push($this->repeats_stack, array($this->repeats, $this->repeat_bytes));
$this->repeat_bytes = xml_get_current_line_number($this->parser) + 1;
}
示例12: spouseFamily
/**
* Find the current spouse family of an individual
*
* @param Individual $individual
*
* @return Family|null
*/
public function spouseFamily(Individual $individual)
{
// Exclude families that were created after this census date
$families = array();
foreach ($individual->getSpouseFamilies() as $family) {
if (Date::compare($family->getMarriageDate(), $this->date()) <= 0) {
$families[] = $family;
}
}
if (empty($families)) {
return null;
} else {
usort($families, function (Family $x, Family $y) {
return Date::compare($x->getMarriageDate(), $y->getMarriageDate());
});
return end($families);
}
}
示例13: isDead
/**
* Is the individual dead.
*
* @param Individual $individual
*
* @return bool
*/
private function isDead(Individual $individual)
{
return $individual->getDeathDate()->isOK() && Date::compare($individual->getDeathDate(), $this->date()) < 0;
}
示例14: familyTable
//.........这里部分代码省略.........
$html .= '</td>';
//-- Event date (sortable)hidden by datatables code
$html .= '<td>';
if ($marriage_dates) {
$html .= $marriage_date->julianDay();
} else {
$html .= 0;
}
$html .= '</td>';
//-- Marriage anniversary
$html .= '<td>' . Date::getAge($mdate, null, 2) . '</td>';
//-- Marriage place
$html .= '<td>';
foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) {
$tmp = new Place($marriage_place, $family->getTree());
if ($n) {
$html .= '<br>';
}
$html .= '<a href="' . $tmp->getURL() . '" title="' . strip_tags($tmp->getFullName()) . '">';
$html .= FunctionsPrint::highlightSearchHits($tmp->getShortName()) . '</a>';
}
$html .= '</td>';
//-- Number of children
$nchi = $family->getNumberOfChildren();
$html .= '<td>' . I18N::number($nchi) . '</td><td>' . $nchi . '</td>';
//-- Last change
$html .= '<td>' . $family->LastChangeTimestamp() . '</td>';
$html .= '<td>' . $family->LastChangeTimestamp(true) . '</td>';
//-- Sorting by marriage date
$html .= '<td>';
if (!$family->canShow() || !$mdate->isOK()) {
$html .= 'U';
} else {
if (Date::compare($mdate, $d100y) > 0) {
$html .= 'Y100';
} else {
$html .= 'YES';
}
}
if ($family->getFacts(WT_EVENTS_DIV)) {
$html .= 'D';
}
if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) {
$html .= 'M';
}
$html .= '</td>';
//-- Sorting alive/dead
$html .= '<td>';
if ($husb->isDead() && $wife->isDead()) {
$html .= 'Y';
}
if ($husb->isDead() && !$wife->isDead()) {
if ($wife->getSex() == 'F') {
$html .= 'H';
}
if ($wife->getSex() == 'M') {
$html .= 'W';
}
// male partners
}
if (!$husb->isDead() && $wife->isDead()) {
if ($husb->getSex() == 'M') {
$html .= 'W';
}
if ($husb->getSex() == 'F') {
$html .= 'H';
示例15: formatFactDate
/**
* Print fact DATE/TIME
*
* @param Fact $event event containing the date/age
* @param GedcomRecord $record the person (or couple) whose ages should be printed
* @param bool $anchor option to print a link to calendar
* @param bool $time option to print TIME value
*
* @return string
*/
public static function formatFactDate(Fact $event, GedcomRecord $record, $anchor, $time)
{
global $pid;
$factrec = $event->getGedcom();
$html = '';
// Recorded age
if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) {
$fact_age = $match[1];
} else {
$fact_age = '';
}
if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) {
$husb_age = $match[1];
} else {
$husb_age = '';
}
if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) {
$wife_age = $match[1];
} else {
$wife_age = '';
}
// Calculated age
if (preg_match('/\\n2 DATE (.+)/', $factrec, $match)) {
$date = new Date($match[1]);
$html .= ' ' . $date->display($anchor);
// time
if ($time && preg_match('/\\n3 TIME (.+)/', $factrec, $match)) {
$html .= ' – <span class="date">' . $match[1] . '</span>';
}
$fact = $event->getTag();
if ($record instanceof Individual) {
if ($fact === 'BIRT' && $record->getTree()->getPreference('SHOW_PARENTS_AGE')) {
// age of parents at child birth
$html .= self::formatParentsAges($record, $date);
} elseif ($fact !== 'CHAN' && $fact !== '_TODO') {
// age at event
$birth_date = $record->getBirthDate();
// Can't use getDeathDate(), as this also gives BURI/CREM events, which
// wouldn't give the correct "days after death" result for people with
// no DEAT.
$death_event = $record->getFirstFact('DEAT');
if ($death_event) {
$death_date = $death_event->getDate();
} else {
$death_date = new Date('');
}
$ageText = '';
if (Date::compare($date, $death_date) <= 0 || !$record->isDead() || $fact == 'DEAT') {
// Before death, print age
$age = Date::getAgeGedcom($birth_date, $date);
// Only show calculated age if it differs from recorded age
if ($age != '') {
if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $record->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $record->getSex() == 'F' && $wife_age != $age) {
if ($age != "0d") {
$ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')';
}
}
}
}
if ($fact != 'DEAT' && Date::compare($date, $death_date) >= 0) {
// After death, print time since death
$age = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($death_date, $date), true);
if ($age != '') {
if (Date::getAgeGedcom($death_date, $date) == "0d") {
$ageText = '(' . I18N::translate('on the date of death') . ')';
} else {
$ageText = '(' . $age . ' ' . I18N::translate('after death') . ')';
// Family events which occur after death are probably errors
if ($event->getParent() instanceof Family) {
$ageText .= '<i class="icon-warning"></i>';
}
}
}
}
if ($ageText) {
$html .= ' <span class="age">' . $ageText . '</span>';
}
}
} elseif ($record instanceof Family) {
$indi = Individual::getInstance($pid, $record->getTree());
if ($indi) {
$birth_date = $indi->getBirthDate();
$death_date = $indi->getDeathDate();
$ageText = '';
if (Date::compare($date, $death_date) <= 0) {
$age = Date::getAgeGedcom($birth_date, $date);
// Only show calculated age if it differs from recorded age
if ($age != '' && $age > 0) {
if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $indi->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $indi->getSex() == 'F' && $wife_age != $age) {
$ageText = '(' . I18N::translate('Age') . ' ' . FunctionsDate::getAgeAtEvent($age, false) . ')';
//.........这里部分代码省略.........