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 09506e3 commit 15cde3b
Showing 1 changed file with 77 additions and 32 deletions.
109 changes: 77 additions & 32 deletions gedcom
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ sub generate
summary => 'Baptism of ' . $person->as_string()
);
}
if(my $marriage = $person->get_record('marriage') || $person->get_record('fams marriage')) {
if(my $marriage = get_marriage($person)) {
if(my $dateofmarriage = $marriage->date()) {
if($dateofmarriage && ($dateofmarriage =~ /^\d+\s\w{3}\s\d{3,4}$/)) {
# FIXME: work with more than one spouse
Expand Down Expand Up @@ -1669,7 +1669,7 @@ sub print_person

return if((!$opts{'l'}) && is_alive($person));

my $marriage = $person->get_record('marriage') || $person->get_record('fams marriage');
my $marriage = get_marriage($person);
# my $dateofmarriage = get_value({ person => $person, value => 'marriage date' });
# if((!$dateofmarriage) && $marriage) {
# $dateofmarriage = $marriage->date();
Expand Down Expand Up @@ -2561,33 +2561,37 @@ sub print_person

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($e->isa('Gedcom::Record')) {
$event = $e;
}
}
if(!defined($marriage)) {
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()) &&
}
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;
}
} else {
foreach my $event(@events) {
if((ref($event) eq 'Gedcom::Record') &&
($event->type() eq 'Custom Marriage')) {
# FindMyPast
$marriage = $event;
last;
}
last;
}
}
}
}

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

my $birth_dt = date_to_datetime(date => $dateofbirth);

if($birth_dt && (my $spouse = $spouses[0])) {
Expand Down Expand Up @@ -6376,15 +6380,18 @@ sub print_person
# TODO - difficult to handle because the field is broken
my $newspaper = newspaper({ gedcom => $ged, person => $person, event => $event });
complain({ person => $person, warning => 'Ignoring Newspaper Death Notice from ' . $newspaper->date() });
# } elsif(($type !~ /^Census U[KS] \d{4}$/) &&
} 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 'Race') &&
($type ne 'Hospitalisation')) {
red_warning({ person => $person, warning => "Unknown event type: $type" });
complain({ person => $person, warning => "Unhandled event type: $type" });
die 'TODO: ', $person->as_string({ nee => 1, include_years => 1, middle_names => 1}), " event type $type";
if(my $notes = notes(record => $event)) {
$notes =~ s/\.$//;
my $date = year(record => $event);
Expand Down Expand Up @@ -10225,7 +10232,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 @@ -11897,19 +11904,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 @@ -11921,6 +11962,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

0 comments on commit 15cde3b

Please sign in to comment.