当前位置: 首页>>代码示例>>PHP>>正文


PHP Date::maximumJulianDay方法代码示例

本文整理汇总了PHP中Fisharebest\Webtrees\Date::maximumJulianDay方法的典型用法代码示例。如果您正苦于以下问题:PHP Date::maximumJulianDay方法的具体用法?PHP Date::maximumJulianDay怎么用?PHP Date::maximumJulianDay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Fisharebest\Webtrees\Date的用法示例。


在下文中一共展示了Date::maximumJulianDay方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ageDifference

 /**
  * Display the age difference between marriages and the births of children.
  *
  * @param Date $prev
  * @param Date $next
  * @param int  $child_number
  *
  * @return string
  */
 private static function ageDifference(Date $prev, Date $next, $child_number = 0)
 {
     if ($prev->isOK() && $next->isOK()) {
         $days = $next->maximumJulianDay() - $prev->minimumJulianDay();
         if ($days < 0) {
             // Show warning triangle if dates in reverse order
             $diff = '<i class="icon-warning"></i> ';
         } elseif ($child_number > 1 && $days > 1 && $days < 240) {
             // Show warning triangle if children born too close together
             $diff = '<i class="icon-warning"></i> ';
         } else {
             $diff = '';
         }
         $months = round($days * 12 / 365.25);
         // Approximate - we do not know the calendar
         if (abs($months) == 12 || abs($months) >= 24) {
             $diff .= I18N::plural('%s year', '%s years', round($months / 12), I18N::number(round($months / 12)));
         } elseif ($months != 0) {
             $diff .= I18N::plural('%s month', '%s months', $months, I18N::number($months));
         }
         return '<div class="elderdate age">' . $diff . '</div>';
     } else {
         return '';
     }
 }
开发者ID:tronsmit,项目名称:webtrees,代码行数:34,代码来源:RelativesTabModule.php

示例2: array

                $tmp = $fact->getDate()->minimumDate();
                if ($tmp->d >= 1 && $tmp->d <= $tmp->daysInMonth()) {
                    // If the day is valid (for its own calendar), display it in the
                    // anniversary day (for the display calendar).
                    $found_facts[$jd - $cal_date->minJD + 1][] = $fact;
                } else {
                    // Otherwise, display it in the "Day not set" box.
                    $found_facts[0][] = $fact;
                }
            }
        }
        break;
    case 'year':
        $cal_date->m = 0;
        $cal_date->setJdFromYmd();
        $found_facts = apply_filter(FunctionsDb::getCalendarEvents($ged_date->minimumJulianDay(), $ged_date->maximumJulianDay(), $filterev, $WT_TREE), $filterof, $filtersx);
        // Eliminate duplicates (e.g. BET JUL 1900 AND SEP 1900 will appear twice in 1900)
        $found_facts = array_unique($found_facts);
        break;
}
// Group the facts by family/individual
$indis = array();
$fams = array();
$cal_facts = array();
switch ($view) {
    case 'year':
    case 'day':
        foreach ($found_facts as $fact) {
            $record = $fact->getParent();
            $xref = $record->getXref();
            if ($record instanceof Individual) {
开发者ID:josefpavlik,项目名称:webtrees,代码行数:31,代码来源:calendar.php

示例3: isDead

 /**
  * Calculate whether this individual is living or dead.
  * If not known to be dead, then assume living.
  *
  * @return bool
  */
 public function isDead()
 {
     $MAX_ALIVE_AGE = $this->tree->getPreference('MAX_ALIVE_AGE');
     // "1 DEAT Y" or "1 DEAT/2 DATE" or "1 DEAT/2 PLAC"
     if (preg_match('/\\n1 (?:' . WT_EVENTS_DEAT . ')(?: Y|(?:\\n[2-9].+)*\\n2 (DATE|PLAC) )/', $this->gedcom)) {
         return true;
     }
     // If any event occured more than $MAX_ALIVE_AGE years ago, then assume the individual is dead
     if (preg_match_all('/\\n2 DATE (.+)/', $this->gedcom, $date_matches)) {
         foreach ($date_matches[1] as $date_match) {
             $date = new Date($date_match);
             if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * $MAX_ALIVE_AGE) {
                 return true;
             }
         }
         // The individual has one or more dated events.  All are less than $MAX_ALIVE_AGE years ago.
         // If one of these is a birth, the individual must be alive.
         if (preg_match('/\\n1 BIRT(?:\\n[2-9].+)*\\n2 DATE /', $this->gedcom)) {
             return false;
         }
     }
     // If we found no conclusive dates then check the dates of close relatives.
     // Check parents (birth and adopted)
     foreach ($this->getChildFamilies(Auth::PRIV_HIDE) as $family) {
         foreach ($family->getSpouses(Auth::PRIV_HIDE) as $parent) {
             // Assume parents are no more than 45 years older than their children
             preg_match_all('/\\n2 DATE (.+)/', $parent->gedcom, $date_matches);
             foreach ($date_matches[1] as $date_match) {
                 $date = new Date($date_match);
                 if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 45)) {
                     return true;
                 }
             }
         }
     }
     // Check spouses
     foreach ($this->getSpouseFamilies(Auth::PRIV_HIDE) as $family) {
         preg_match_all('/\\n2 DATE (.+)/', $family->gedcom, $date_matches);
         foreach ($date_matches[1] as $date_match) {
             $date = new Date($date_match);
             // Assume marriage occurs after age of 10
             if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 10)) {
                 return true;
             }
         }
         // Check spouse dates
         $spouse = $family->getSpouse($this);
         if ($spouse) {
             preg_match_all('/\\n2 DATE (.+)/', $spouse->gedcom, $date_matches);
             foreach ($date_matches[1] as $date_match) {
                 $date = new Date($date_match);
                 // Assume max age difference between spouses of 40 years
                 if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 40)) {
                     return true;
                 }
             }
         }
         // Check child dates
         foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) {
             preg_match_all('/\\n2 DATE (.+)/', $child->gedcom, $date_matches);
             // Assume children born after age of 15
             foreach ($date_matches[1] as $date_match) {
                 $date = new Date($date_match);
                 if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 15)) {
                     return true;
                 }
             }
             // Check grandchildren
             foreach ($child->getSpouseFamilies(Auth::PRIV_HIDE) as $child_family) {
                 foreach ($child_family->getChildren(Auth::PRIV_HIDE) as $grandchild) {
                     preg_match_all('/\\n2 DATE (.+)/', $grandchild->gedcom, $date_matches);
                     // Assume grandchildren born after age of 30
                     foreach ($date_matches[1] as $date_match) {
                         $date = new Date($date_match);
                         if ($date->isOK() && $date->maximumJulianDay() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 30)) {
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:bmhm,项目名称:webtrees,代码行数:90,代码来源:Individual.php

示例4: advancedSearch


//.........这里部分代码省略.........
                             // SDX uses DM by default.
                         // SDX uses DM by default.
                         case 'SDX_DM':
                             $sdx = Soundex::daitchMokotoff($value);
                             if ($sdx !== null) {
                                 $sdx = explode(':', $sdx);
                                 foreach ($sdx as $k => $v) {
                                     $sdx[$k] = "i_n.n_soundex_surn_dm LIKE CONCAT('%', ?, '%')";
                                     $bind[] = $v;
                                 }
                                 $sql .= " AND (" . implode(' OR ', $sdx) . ")";
                                 break;
                             } else {
                                 // No phonetic content?  Use a substring match
                                 $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')";
                                 $bind[] = $value;
                             }
                     }
                     break;
                 case 'NICK':
                 case '_MARNM':
                 case '_HEB':
                 case '_AKA':
                     $sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')";
                     $bind[] = $parts[1];
                     $bind[] = $value;
                     break;
             }
         } elseif ($parts[1] == 'DATE') {
             // *:DATE
             $date = new Date($value);
             if ($date->isOK()) {
                 $jd1 = $date->minimumJulianDay();
                 $jd2 = $date->maximumJulianDay();
                 if (!empty($this->plusminus[$i])) {
                     $adjd = $this->plusminus[$i] * 365;
                     $jd1 -= $adjd;
                     $jd2 += $adjd;
                 }
                 $sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?";
                 $bind[] = $parts[0];
                 $bind[] = $jd1;
                 $bind[] = $jd2;
             }
         } elseif ($parts[0] == 'FAMS' && $parts[2] == 'DATE') {
             // FAMS:*:DATE
             $date = new Date($value);
             if ($date->isOK()) {
                 $jd1 = $date->minimumJulianDay();
                 $jd2 = $date->maximumJulianDay();
                 if (!empty($this->plusminus[$i])) {
                     $adjd = $this->plusminus[$i] * 365;
                     $jd1 -= $adjd;
                     $jd2 += $adjd;
                 }
                 $sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?";
                 $bind[] = $parts[1];
                 $bind[] = $jd1;
                 $bind[] = $jd2;
             }
         } elseif ($parts[1] == 'PLAC') {
             // *:PLAC
             // SQL can only link a place to a person/family, not to an event.
             $sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')";
             $bind[] = $value;
         } elseif ($parts[0] == 'FAMS' && $parts[2] == 'PLAC') {
开发者ID:tunandras,项目名称:webtrees,代码行数:67,代码来源:AdvancedSearchController.php

示例5: 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;
     }
 }
开发者ID:pal-saugstad,项目名称:webtrees,代码行数:56,代码来源:Date.php

示例6: listStartHandler

 /**
  * XML <List>
  *
  * @param array $attrs an array of key value pairs for the attributes
  */
 private function listStartHandler($attrs)
 {
     global $WT_TREE;
     $this->process_repeats++;
     if ($this->process_repeats > 1) {
         return;
     }
     $match = array();
     if (isset($attrs['sortby'])) {
         $sortby = $attrs['sortby'];
         if (preg_match("/\\\$(\\w+)/", $sortby, $match)) {
             $sortby = $this->vars[$match[1]]['id'];
             $sortby = trim($sortby);
         }
     } else {
         $sortby = "NAME";
     }
     if (isset($attrs['list'])) {
         $listname = $attrs['list'];
     } else {
         $listname = "individual";
     }
     // Some filters/sorts can be applied using SQL, while others require PHP
     switch ($listname) {
         case "pending":
             $rows = Database::prepare("SELECT xref, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" . " FROM `##change`" . " WHERE (xref, change_id) IN (" . "  SELECT xref, MAX(change_id)" . "  FROM `##change`" . "  WHERE status = 'pending' AND gedcom_id = :tree_id" . "  GROUP BY xref" . " )")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchAll();
             $this->list = array();
             foreach ($rows as $row) {
                 $this->list[] = GedcomRecord::getInstance($row->xref, $WT_TREE, $row->gedcom);
             }
             break;
         case 'individual':
             $sql_select = "SELECT i_id AS xref, i_gedcom AS gedcom FROM `##individuals` ";
             $sql_join = "";
             $sql_where = " WHERE i_file = :tree_id";
             $sql_order_by = "";
             $sql_params = array('tree_id' => $WT_TREE->getTreeId());
             foreach ($attrs as $attr => $value) {
                 if (strpos($attr, 'filter') === 0 && $value) {
                     $value = $this->substituteVars($value, false);
                     // Convert the various filters into SQL
                     if (preg_match('/^(\\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) {
                         $sql_join .= " JOIN `##dates` AS {$attr} ON ({$attr}.d_file=i_file AND {$attr}.d_gid=i_id)";
                         $sql_where .= " AND {$attr}.d_fact = :{$attr}fact";
                         $sql_params[$attr . 'fact'] = $match[1];
                         $date = new Date($match[3]);
                         if ($match[2] == "LTE") {
                             $sql_where .= " AND {$attr}.d_julianday2 <= :{$attr}date";
                             $sql_params[$attr . 'date'] = $date->maximumJulianDay();
                         } else {
                             $sql_where .= " AND {$attr}.d_julianday1 >= :{$attr}date";
                             $sql_params[$attr . 'date'] = $date->minimumJulianDay();
                         }
                         if ($sortby == $match[1]) {
                             $sortby = "";
                             $sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.d_julianday1";
                         }
                         unset($attrs[$attr]);
                         // This filter has been fully processed
                     } elseif (preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) {
                         // Do nothing, unless you have to
                         if ($match[1] != '' || $sortby == 'NAME') {
                             $sql_join .= " JOIN `##name` AS {$attr} ON (n_file=i_file AND n_id=i_id)";
                             // Search the DB only if there is any name supplied
                             if ($match[1] != "") {
                                 $names = explode(" ", $match[1]);
                                 foreach ($names as $n => $name) {
                                     $sql_where .= " AND {$attr}.n_full LIKE CONCAT('%', :{$attr}name{$n}, '%')";
                                     $sql_params[$attr . 'name' . $n] = $name;
                                 }
                             }
                             // Let the DB do the name sorting even when no name was entered
                             if ($sortby == "NAME") {
                                 $sortby = "";
                                 $sql_order_by .= ($sql_order_by ? ", " : " ORDER BY ") . "{$attr}.n_sort";
                             }
                         }
                         unset($attrs[$attr]);
                         // This filter has been fully processed
                     } elseif (preg_match('/^REGEXP \\/(.+)\\//', $value, $match)) {
                         $sql_where .= " AND i_gedcom REGEXP :{$attr}gedcom";
                         // PDO helpfully escapes backslashes for us, preventing us from matching "\n1 FACT"
                         $sql_params[$attr . 'gedcom'] = str_replace('\\n', "\n", $match[1]);
                         unset($attrs[$attr]);
                         // This filter has been fully processed
                     } elseif (preg_match('/^(?:\\w+):PLAC CONTAINS (.+)$/', $value, $match)) {
                         $sql_join .= " JOIN `##places` AS {$attr}a ON ({$attr}a.p_file = i_file)";
                         $sql_join .= " JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file = {$attr}b.pl_file AND {$attr}b.pl_p_id = {$attr}a.p_id AND {$attr}b.pl_gid = i_id)";
                         $sql_where .= " AND {$attr}a.p_place LIKE CONCAT('%', :{$attr}place, '%')";
                         $sql_params[$attr . 'place'] = $match[1];
                         // Don't unset this filter. This is just initial filtering
                     } elseif (preg_match('/^(\\w*):*(\\w*) CONTAINS (.+)$/', $value, $match)) {
                         $sql_where .= " AND i_gedcom LIKE CONCAT('%', :{$attr}contains1, '%', :{$attr}contains2, '%', :{$attr}contains3, '%')";
                         $sql_params[$attr . 'contains1'] = $match[1];
                         $sql_params[$attr . 'contains2'] = $match[2];
//.........这里部分代码省略.........
开发者ID:tronsmit,项目名称:webtrees,代码行数:101,代码来源:ReportParserGenerate.php


注:本文中的Fisharebest\Webtrees\Date::maximumJulianDay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。