line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gedcom::Date::Range; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
22
|
use strict; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
159
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
20
|
use vars qw($VERSION @ISA); |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
308
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
8
|
|
|
|
|
|
|
@ISA = qw/Gedcom::Date/; |
9
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
22
|
use Gedcom::Date; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
2505
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub parse { |
13
|
41
|
|
|
41
|
1
|
36
|
my $class = shift; |
14
|
41
|
|
|
|
|
38
|
my ($str) = @_; |
15
|
|
|
|
|
|
|
|
16
|
41
|
|
|
|
|
30
|
my ($aft, $bef); |
17
|
41
|
100
|
|
|
|
129
|
if ($str =~ /^BET (.*?) AND (.*)$/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
18
|
3
|
50
|
|
|
|
13
|
$aft = Gedcom::Date::Simple->parse($1) or return; |
19
|
3
|
50
|
|
|
|
10
|
$bef = Gedcom::Date::Simple->parse($2) or return; |
20
|
|
|
|
|
|
|
} elsif ($str =~ /^AFT (.*)$/) { |
21
|
3
|
50
|
|
|
|
20
|
$aft = Gedcom::Date::Simple->parse($1) or return; |
22
|
|
|
|
|
|
|
} elsif ($str =~ /^BEF (.*)$/) { |
23
|
3
|
50
|
|
|
|
12
|
$bef = Gedcom::Date::Simple->parse($1) or return; |
24
|
|
|
|
|
|
|
} else { |
25
|
32
|
|
|
|
|
195
|
return; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
9
|
|
|
|
|
24
|
my $self = bless { |
29
|
|
|
|
|
|
|
aft => $aft, |
30
|
|
|
|
|
|
|
bef => $bef |
31
|
|
|
|
|
|
|
}, $class; |
32
|
|
|
|
|
|
|
|
33
|
9
|
|
|
|
|
133
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub gedcom { |
37
|
6
|
|
|
6
|
1
|
527
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
6
|
50
|
|
|
|
15
|
if (!defined $self->{gedcom}) { |
40
|
6
|
100
|
100
|
|
|
28
|
if (defined($self->{aft}) && defined($self->{bef})) { |
|
|
100
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$self->{gedcom} = 'BET ' . $self->{aft}->gedcom() . |
42
|
2
|
|
|
|
|
8
|
' AND ' . $self->{bef}->gedcom(); |
43
|
|
|
|
|
|
|
} elsif (defined($self->{aft})) { |
44
|
2
|
|
|
|
|
35
|
$self->{gedcom} = 'AFT ' . $self->{aft}->gedcom(); |
45
|
|
|
|
|
|
|
} else { |
46
|
2
|
|
|
|
|
8
|
$self->{gedcom} = 'BEF ' . $self->{bef}->gedcom(); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
20
|
$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
|
11
|
my ($self, $lang) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $type = defined($self->{bef}) ? |
91
|
9
|
100
|
|
|
|
26
|
(defined($self->{aft}) ? 2 : 1 ) : 0; |
|
|
100
|
|
|
|
|
|
92
|
9
|
|
|
|
|
27
|
return ($text{$lang}[$type], $self->{aft}, $self->{bef}); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |