Skip to content

Commit

Permalink
Handle more date formats in datecmp()
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Sep 5, 2023
1 parent d1183e8 commit 86bfa67
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ged2site
Original file line number Diff line number Diff line change
Expand Up @@ -4186,7 +4186,6 @@ sub print_person
if(defined($dateofmarriage) && (scalar(@spouses) == 2) && ($spouse_number == 2)) {
my $death_of_first_spouse = dateofdeath($spouses[0]);
if($death_of_first_spouse &&
($death_of_first_spouse !~ /[a-z]{3}\/[a-z]{3}/i) &&
(datecmp($dateofmarriage, $death_of_first_spouse) > 0)) {
if($printed_bracket) {
$bio .= ', ';
Expand Down Expand Up @@ -12116,6 +12115,19 @@ sub datecmp($$)
# }
my @r = $dfg->parse_datetime($right);
if(!defined($r[0])) {
if($right =~ /\s(\d{4})$/) {
# e.g. cmp "1891 <=> Oct/Nov/Dec 1892"
my $year = $1;
if(ref($left)) {
if($left->year() != $year) {
return $left->year() <=> $year;
}
} else {
if($left != $year) {
return $left <=> $year;
}
}
}
# TODO: throw an error that we can catch
my $i = 0;
while((my @call_details = caller($i++))) {
Expand Down

0 comments on commit 86bfa67

Please sign in to comment.