Exemplo n.º 1
0
 static function ageDifference(WT_Date $prev, WT_Date $next, $child_number = 0)
 {
     if ($prev->isOK() && $next->isOK()) {
         $days = $next->MaxJD() - $prev->MinJD();
         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 .= WT_I18N::plural('%d year', '%d years', round($months / 12), round($months / 12));
         } elseif ($months != 0) {
             $diff .= WT_I18N::plural('%d month', '%d months', $months, $months);
         }
         return '<div class="elderdate age">' . $diff . '</div>';
     } else {
         return '';
     }
 }
Exemplo n.º 2
0
        for ($jd = $cal_date->minJD; $jd <= $cal_date->maxJD; ++$jd) {
            foreach (apply_filter(get_anniversary_events($jd, $events), $filterof, $filtersx) as $fact) {
                $tmp = $fact->getDate()->MinDate();
                if ($tmp->d >= 1 && $tmp->d <= $tmp->DaysInMonth()) {
                    $d = $jd - $cal_date->minJD + 1;
                } else {
                    $d = 0;
                }
                $found_facts[$d][] = $fact;
            }
        }
        break;
    case 'year':
        $cal_date->m = 0;
        $cal_date->setJdFromYmd();
        $found_facts = apply_filter(get_calendar_events($ged_date->MinJD(), $ged_date->MaxJD(), $events), $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
switch ($action) {
    case 'year':
    case 'today':
        $indis = array();
        $fams = array();
        foreach ($found_facts as $fact) {
            $record = $fact->getParent();
            $xref = $record->getXref();
            if ($record instanceof WT_Individual) {
                if (empty($indis[$xref])) {
Exemplo n.º 3
0
 static function getAge(WT_Date $d1, WT_Date $d2 = null, $format)
 {
     if ($d2) {
         if ($d2->MaxJD() >= $d1->MinJD() && $d2->MinJD() <= $d1->MinJD()) {
             // Overlapping dates
             $jd = $d1->MinJD();
         } else {
             // Non-overlapping dates
             $jd = $d2->MinJD();
         }
     } else {
         // If second date not specified, use today’s date
         $jd = WT_CLIENT_JD;
     }
     switch ($format) {
         case 0:
             // Years - integer only (for statistics, rather than for display)
             if ($jd && $d1->MinJD() && $d1->MinJD() <= $jd) {
                 return $d1->MinDate()->GetAge(false, $jd, false);
             } else {
                 return -1;
             }
         case 1:
             // Days - integer only (for sorting, rather than for display)
             if ($jd && $d1->MinJD()) {
                 return $jd - $d1->MinJD();
             } else {
                 return -1;
             }
         case 2:
             // Just years, in local digits, with warning for negative/
             if ($jd && $d1->MinJD()) {
                 if ($d1->MinJD() > $jd) {
                     return '<i class="icon-warning"></i>';
                 } else {
                     return WT_I18N::number($d1->MinDate()->GetAge(false, $jd));
                 }
             } else {
                 return '&nbsp;';
             }
             // TODO: combine GetAgeGedcom() into this function
     }
 }