Skip to content

Commit dc91086

Browse files
committed
Fix error when import gedcom file
1 parent 5d6ecbf commit dc91086

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
lines changed

src/Parser/Date.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public static function parse(\Gedcom\Parser $parser)
2020
{
2121
$record = $parser->getCurrentLineRecord();
2222
$depth = (int) $record[0];
23+
24+
$parser->forward();
25+
$record = $parser->getCurrentLineRecord();
26+
2327
if (isset($record[1])) {
2428
$dat = new \Gedcom\Record\Date();
2529
if (!empty($record[2])) {
@@ -30,7 +34,11 @@ public static function parse(\Gedcom\Parser $parser)
3034

3135
return null;
3236
}
37+
38+
if ($dat->getYear() && $dat->getMonth() && $dat->getDay()) {
39+
return $dat->getYear() .'-'. substr("0{$dat->getMonth()}", -2) .'-'. substr("0{$dat->getDay()}", -2);
40+
}
3341

34-
return $dat;
42+
return null;
3543
}
3644
}

src/Parser/Head/Sour.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function parse(\Gedcom\Parser $parser)
4949
$source->setName(trim($record[2]));
5050
break;
5151
case 'CORP':
52-
$corp = Parser\Head\Sour\Corp::parse($parser);
52+
$corp = \Gedcom\Parser\Head\Sour\Corp::parse($parser);
5353
$source->setCorp($corp);
5454
break;
5555
case 'DATA':

src/Parser/Head/Sour/Corp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function parse(\Gedcom\Parser $parser)
4343

4444
switch ($recordType) {
4545
case 'ADDR':
46-
$corp->setAddr(\Parser\Addr::parse($parser));
46+
$corp->setAddr(\Gedcom\Parser\Addr::parse($parser));
4747
break;
4848
case 'PHON':
4949
$corp->addPhon(trim($record[2]));

src/Parser/Indi.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public static function parse(\Gedcom\Parser $parser)
6161
break;
6262
case 'ADOP':
6363
case 'BIRT':
64+
$birthday = \Gedcom\Parser\Date::parse($parser);
65+
$indi->setBirthday($birthday);
66+
break;
6467
case 'BAPM':
6568
case 'BARM':
6669
case 'BASM':
@@ -72,6 +75,7 @@ public static function parse(\Gedcom\Parser $parser)
7275
case 'CONF':
7376
case 'CREM':
7477
case 'DEAT':
78+
break;
7579
case 'EMIG':
7680
case 'FCOM':
7781
case 'GRAD':

src/Parser/Sour.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function parse(\Gedcom\Parser $parser)
4747

4848
switch ($recordType) {
4949
case 'DATA':
50-
$sour->setData(\Parser\Sour\Data::parse($parser));
50+
$sour->setData(\Gedcom\Parser\Sour\Data::parse($parser));
5151
break;
5252
case 'AUTH':
5353
$sour->setAuth($parser->parseMultilineRecord());
@@ -65,7 +65,7 @@ public static function parse(\Gedcom\Parser $parser)
6565
$sour->setText($parser->parseMultilineRecord());
6666
break;
6767
case 'REPO':
68-
$sour->setRepo(\Parser\Sour\Repo::parse($parser));
68+
$sour->setRepo(\Gedcom\Parser\Sour\Repo::parse($parser));
6969
break;
7070
case 'REFN':
7171
$refn = \Gedcom\Parser\Refn::parse($parser);

src/Record/Indi.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ class Indi extends \Gedcom\Record implements Noteable, Objectable, Sourceable
138138
* @var Indi\Asso[]
139139
*/
140140
protected $asso = [];
141+
142+
protected $birthday;
143+
144+
public function setBirthday($birthday = '')
145+
{
146+
$this->birthday = $birthday;
147+
148+
return $this;
149+
}
150+
151+
public function getBirthday()
152+
{
153+
return $this->birthday;
154+
}
141155

142156
/**
143157
* @param string $id

0 commit comments

Comments
 (0)