line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gedcom::Date::Range; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
40
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
259
|
|
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
36
|
use vars qw($VERSION @ISA); |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
476
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
8
|
|
|
|
|
|
|
@ISA = qw/Gedcom::Date/; |
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
35
|
use Gedcom::Date; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
4359
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub parse { |
13
|
41
|
|
|
41
|
1
|
67
|
my $class = shift; |
14
|
41
|
|
|
|
|
66
|
my ($str) = @_; |
15
|
|
|
|
|
|
|
|
16
|
41
|
|
|
|
|
47
|
my ($aft, $bef); |
17
|
41
|
100
|
|
|
|
215
|
if ($str =~ /^BET (.*?) AND (.*)$/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
18
|
3
|
50
|
|
|
|
18
|
$aft = Gedcom::Date::Simple->parse($1) or return; |
19
|
3
|
50
|
|
|
|
12
|
$bef = Gedcom::Date::Simple->parse($2) or return; |
20
|
|
|
|
|
|
|
} elsif ($str =~ /^AFT (.*)$/) { |
21
|
3
|
50
|
|
|
|
48
|
$aft = Gedcom::Date::Simple->parse($1) or return; |
22
|
|
|
|
|
|
|
} elsif ($str =~ /^BEF (.*)$/) { |
23
|
3
|
50
|
|
|
|
18
|
$bef = Gedcom::Date::Simple->parse($1) or return; |
24
|
|
|
|
|
|
|
} else { |
25
|
32
|
|
|
|
|
369
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
9
|
|
|
|
|
38
|
my $self = bless { |
29
|
|
|
|
|
|
|
aft => $aft, |
30
|
|
|
|
|
|
|
bef => $bef |
31
|
|
|
|
|
|
|
}, $class; |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
248
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub gedcom { |
37
|
6
|
|
|
6
|
1
|
1497
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
6
|
50
|
|
|
|
26
|
if (!defined $self->{gedcom}) { |
40
|
6
|
100
|
100
|
|
|
43
|
if (defined($self->{aft}) && defined($self->{bef})) { |
|
|
100
|
|
|
|
|
|
41
|
2
|
|
|
|
|
11
|
$self->{gedcom} = 'BET ' . $self->{aft}->gedcom() . |
42
|
|
|
|
|
|
|
' AND ' . $self->{bef}->gedcom(); |
43
|
|
|
|
|
|
|
} elsif (defined($self->{aft})) { |
44
|
2
|
|
|
|
|
12
|
$self->{gedcom} = 'AFT ' . $self->{aft}->gedcom(); |
45
|
|
|
|
|
|
|
} else { |
46
|
2
|
|
|
|
|
12
|
$self->{gedcom} = 'BEF ' . $self->{bef}->gedcom(); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
31
|
$self->{gedcom}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub latest { |
53
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
|
|
0
|
if ($self->{bef}) { |
56
|
0
|
|
|
|
|
0
|
return $self->{bef}->latest; |
57
|
|
|
|
|
|
|
} else { |
58
|
0
|
|
|
|
|
0
|
return DateTime::Infinite::Future->new; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub earliest { |
63
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
if ($self->{aft}) { |
66
|
0
|
|
|
|
|
0
|
return $self->{aft}->earliest; |
67
|
|
|
|
|
|
|
} else { |
68
|
0
|
|
|
|
|
0
|
return DateTime::Infinite::Past->new; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub sort_date { |
73
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
0
|
if (defined $self->{aft}) { |
76
|
0
|
|
|
|
|
0
|
return $self->{aft}->sort_date; |
77
|
|
|
|
|
|
|
} else { |
78
|
0
|
|
|
|
|
0
|
return $self->{bef}->sort_date; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my %text = ( |
83
|
|
|
|
|
|
|
en => ['after %0', 'before %1', 'between %0 and %1'], |
84
|
|
|
|
|
|
|
nl => ['na %0', 'voor %1', 'tussen %0 en %1'], |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub text_format { |
88
|
9
|
|
|
9
|
0
|
16
|
my ($self, $lang) = @_; |
89
|
|
|
|
|
|
|
|
90
|
9
|
100
|
|
|
|
35
|
my $type = defined($self->{bef}) ? |
|
|
100
|
|
|
|
|
|
91
|
|
|
|
|
|
|
(defined($self->{aft}) ? 2 : 1 ) : 0; |
92
|
9
|
|
|
|
|
43
|
return ($text{$lang}[$type], $self->{aft}, $self->{bef}); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |