Skip to content

Commit

Permalink
Try harder to get the marriage record
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Aug 1, 2024
1 parent 5706857 commit ff24efd
Showing 1 changed file with 62 additions and 41 deletions.
103 changes: 62 additions & 41 deletions ged2site
Original file line number Diff line number Diff line change
Expand Up @@ -2452,35 +2452,12 @@ sub print_person
}
}

my $marriage = $person->get_record('marriage') || $person->get_record('fams marriage');
if((!defined($marriage)) && scalar(@spouses)) {
$marriage = $spouses[0]->get_record('marriage');
if(!defined($marriage)) {
if(scalar(@events) == 1) {
my $event = $person->event();
if(!ref($event)) {
my $e = $person->tag_record('EVEN');
if(ref($e) eq 'Gedcom::Record') {
$event = $e;
}
}
if($event->can('type') && defined($event->type()) &&
($event->type() eq 'Custom Marriage')) {
# FindMyPast
$marriage = $event;
}
} else {
foreach my $event(@events) {
if((ref($event) eq 'Gedcom::Record') &&
($event->type() eq 'Custom Marriage')) {
# FindMyPast
$marriage = $event;
last;
}
}
}
}
my $marriage = get_marriage($person);

if(defined($marriage) && (scalar(@spouses) == 0)) {
complain({ person => $person, warning => 'Marriage record not used to determine spouse' });
}

my $placeofmarriage = get_value({ person => $person, value => 'marriage place' });
if((!$placeofmarriage) && $marriage) {
$placeofmarriage = $marriage->place();
Expand Down Expand Up @@ -2563,7 +2540,7 @@ sub print_person
# complain({ person => $person, warning => 'Removing trailing spaces from date of marriage' });
# $dateofmarriage =~ s/\s+$//;
# }
my $dateofmarriage = dateofmarriage($person);
my $dateofmarriage = dateofmarriage(person => $person);
my $marriage_dt;
if($dateofmarriage) {
$marriage_dt = $dfg->parse_datetime(date => $dateofmarriage, quiet => 1);
Expand Down Expand Up @@ -7111,12 +7088,18 @@ sub print_person
complain({ person => $person, warning => 'Ignoring Newspaper Death Notice from ' . $newspaper->date() });
} elsif($type eq 'Funeral') {
$funeral = $event;
} elsif($type eq 'Custom Marriage') {
die 'BUG: ', $person->as_string(), ' missed custom marriage' if(!defined($marriage));
# } elsif(($type !~ /^Census U[KS] \d{4}$/) &&
} elsif(($type !~ /Census/) &&
($type ne 'Register UK 1939') &&
($type ne 'Race') &&
($type ne 'Hospitalisation')) {
red_warning({ person => $person, warning => "Unknown event type: $type" });
complain({ person => $person, warning => "Unhandled event type: $type" });
if($dateofmarriage) {
warn $dateofmarriage;
}
die 'TODO: ', $person->as_string({ nee => 1, include_years => 1, middle_names => 1}), " event type $type";
if(my $notes = notes(record => $event, note_locations => \@note_locations)) {
$notes =~ s/[\s\.]+$//;
my $date = year(record => $event);
Expand Down Expand Up @@ -11876,7 +11859,7 @@ sub places_are_the_same
return 0 if($params{'exact'});
if(compare($place1, $place2) > 0.5) {
if($person) {
complain({ $person => $person, warning => "The places '$place1' and '$place2' seem similar; is there a typo?" });
complain({ person => $person, warning => "The places '$place1' and '$place2' seem similar; is there a typo?" });
} else {
complain("The places '$place1' and '$place2' seem similar; is there a typo?");
}
Expand Down Expand Up @@ -13581,19 +13564,53 @@ sub dateofbirth {
return; # return undef
}

sub dateofmarriage
# Try hard to get the marriage record
sub get_marriage
{
my %params;
my $params = get_params('person', @_);
my $person = $params->{'person'};

if(ref($_[0]) eq 'HASH') {
%params = %{$_[0]};
} elsif(scalar(@_) % 2 == 0) {
%params = @_;
} else {
$params{'person'} = shift;
my $marriage = $person->get_record('marriage') || $person->get_record('fams marriage');
if(!defined($marriage)) {
my @spouses = $person->spouse();
if(scalar(@spouses)) {
# FIXME: only looks at the first spouse
$marriage = $spouses[0]->get_record('marriage') || $spouses[0]->get_record('fams marriage');
return $marriage if(defined($marriage));
}

my @events = $person->event();
if(scalar(@events) == 1) {
my $event = $person->event();
if(!ref($event)) {
my $e = $person->tag_record('EVEN');
if($e->isa('Gedcom::Record')) {
$event = $e;
}
}
if($event->can('type') && defined($event->type()) &&
($event->type() eq 'Custom Marriage')) {
# FindMyPast
return $event;
}
} else {
foreach my $event(@events) {
if((ref($event) eq 'Gedcom::Record') &&
($event->type() eq 'Custom Marriage')) {
# FindMyPast
return $event;
}
}
}
}
return $marriage;
}

my $person = $params{'person'};
sub dateofmarriage
{
my $params = get_params('person', @_);

my $person = $params->{'person'};

# my $dateofmarriage = get_value({ person => $person, value => 'marriage date' });
# if((!defined($dateofmarriage)) && (my $marriage = $person->get_record('marriage') || $person->get_record('fams marriage'))) {
Expand All @@ -13605,6 +13622,10 @@ sub dateofmarriage
my @d = get_value({ person => $person, value => 'marriage date' });
my $dateofmarriage;

if((scalar(@d) == 0) && (my $marriage = get_marriage($person))) {
@d = $marriage->date();
}

if(scalar(@d) == 2) { # TODO: && dates not the same
my ($year1, $year2);

Expand Down Expand Up @@ -13645,7 +13666,7 @@ sub dateofmarriage
return;
}

if((!defined($dateofmarriage)) && (my $marriage = $person->get_record('marriage') // $person->get_record('fams marriage'))) {
if((!defined($dateofmarriage)) && (my $marriage = get_marriage($person))) {
$dateofmarriage = $marriage->date();
}
if(defined($dateofmarriage)) {
Expand Down

0 comments on commit ff24efd

Please sign in to comment.