diff --git a/src/Services/TimeValueBuilder.php b/src/Services/TimeValueBuilder.php index 2b578db..66fe721 100644 --- a/src/Services/TimeValueBuilder.php +++ b/src/Services/TimeValueBuilder.php @@ -9,6 +9,7 @@ use EDTF\EdtfValue; use EDTF\Model\ExtDate; use EDTF\Model\ExtDateTime; +use EDTF\Model\Interval; use EDTF\Model\Season; use EDTF\Model\Set; @@ -33,6 +34,13 @@ public function edtfToTimeValues( string $edtfString ): array { ); } + if ( $edtf instanceof Interval ) { + return [ + $this->singleValueEdtfToTimeValue( $edtf->getStartDate() ), + $this->singleValueEdtfToTimeValue( $edtf->getEndDate() ) + ]; + } + return [ $this->singleValueEdtfToTimeValue( $edtf ) ]; diff --git a/tests/php/Unit/TimeValueBuilderTest.php b/tests/php/Unit/TimeValueBuilderTest.php index a6a45f3..aaafde3 100644 --- a/tests/php/Unit/TimeValueBuilderTest.php +++ b/tests/php/Unit/TimeValueBuilderTest.php @@ -102,9 +102,19 @@ public function testSet(): void { public function testSeason(): void { $this->assertEquals( - $this->newTimeValue( '+2021-01-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ), + $this->newTimeValue( '+2021-01-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ), // TODO $this->edtfToTimeValue( '2021-21' ) ); } + public function testInterval(): void { + $this->assertEquals( + [ + $this->newTimeValue( '+2020-11-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ), + $this->newTimeValue( '+2021-03-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ) + ], + $this->edtfToMultipleTimeValues( '2020-11/2021-03' ) + ); + } + }