summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfisharebest <fisharebest@gmail.com>2013-07-05 18:45:41 +0000
committerfisharebest <fisharebest@gmail.com>2013-07-05 18:45:41 +0000
commit78086a33d282a21b558a1fed0280b43487159efb (patch)
tree71008bb7c7e3bebca010136f1463a2c2363a18cc
parent90e1d7f65690a7e14e5ac530357ef73eca33fb42 (diff)
downloadwebtrees-78086a33d282a21b558a1fed0280b43487159efb.tar.gz
webtrees-78086a33d282a21b558a1fed0280b43487159efb.tar.bz2
webtrees-78086a33d282a21b558a1fed0280b43487159efb.zip
More refactoring - compareChanDate()
-rw-r--r--library/WT/GedcomRecord.php19
-rw-r--r--library/WT/Report/Base.php20
2 files changed, 19 insertions, 20 deletions
diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php
index 8c18699fe6..f81e82c135 100644
--- a/library/WT/GedcomRecord.php
+++ b/library/WT/GedcomRecord.php
@@ -570,25 +570,6 @@ class WT_GedcomRecord {
}
}
- // Static helper function to sort an array of objects by Change Date
- static function CompareChanDate($x, $y) {
- $chan_x = $x->getChangeEvent();
- $chan_y = $y->getChangeEvent();
- $tmp=WT_Date::Compare($chan_x->getDate(), $chan_y->getDate());
- if ($tmp) {
- return $tmp;
- } else {
- if (
- preg_match('/^\d\d:\d\d:\d\d/', get_gedcom_value('DATE:TIME', 2, $chan_x->getGedcom()).':00', $match_x) &&
- preg_match('/^\d\d:\d\d:\d\d/', get_gedcom_value('DATE:TIME', 2, $chan_y->getGedcom()).':00', $match_y)
- ) {
- return strcmp($match_x[0], $match_y[0]);
- } else {
- return 0;
- }
- }
- }
-
// Get variants of the name
public function getFullName() {
if ($this->canShowName()) {
diff --git a/library/WT/Report/Base.php b/library/WT/Report/Base.php
index e39b81b338..4d058ff8ca 100644
--- a/library/WT/Report/Base.php
+++ b/library/WT/Report/Base.php
@@ -3231,7 +3231,25 @@ function ListSHandler($attrs) {
uasort($list, array("WT_GedcomRecord", "Compare"));
break;
case "CHAN":
- uasort($list, array("WT_GedcomRecord", "CompareChanDate"));
+ uasort($list, function($x, $y) {
+ $f1 = $x->getFactByType('CHAN');
+ $f2 = $y->getFactByType('CHAN');
+ if ($f1 && $f2) {
+ $d1 = $f1->getDate();
+ $d2 = $f2->getDate();
+ $cmp = WT_Date::compare($d1, $d2);
+ if ($cmp) {
+ return $cmp;
+ } else {
+ // Same date. Compare times
+ preg_match('/\n3 TIME (.+)/', $f1->getGedcom(), $m1);
+ preg_match('/\n3 TIME (.+)/', $f2->getGedcom(), $m2);
+ return strcmp($m1[1], $m2[1]);
+ }
+ } else {
+ return 0;
+ }
+ });
break;
case "BIRT:DATE":
uasort($list, array("WT_Individual", "CompareBirtDate"));