Skip to content

Commit

Permalink
Add stub Season implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Mar 13, 2021
1 parent 3444b68 commit 3ec42cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Services/TimeValueBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use EDTF\EdtfValue;
use EDTF\Model\ExtDate;
use EDTF\Model\ExtDateTime;
use EDTF\Model\Season;
use EDTF\Model\Set;

class TimeValueBuilder {
Expand Down Expand Up @@ -54,6 +55,13 @@ private function singleValueEdtfToTimeValue( EdtfValue $edtf ): TimeValue {
);
}

if ( $edtf instanceof Season ) {
return $this->singleValueEdtfToTimeValue( new ExtDate(
$edtf->getYear(),
1 // TODO
) );
}

throw new \InvalidArgumentException();
}

Expand Down
7 changes: 7 additions & 0 deletions tests/php/Unit/TimeValueBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ public function testSet(): void {
);
}

public function testSeason(): void {
$this->assertEquals(
$this->newTimeValue( '+2021-01-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ),
$this->edtfToTimeValue( '2021-21' )
);
}

}

0 comments on commit 3ec42cb

Please sign in to comment.