Skip to content

Commit 1d9f772

Browse files
committed
Add interval support
1 parent 3ec42cb commit 1d9f772

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Services/TimeValueBuilder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use EDTF\EdtfValue;
1010
use EDTF\Model\ExtDate;
1111
use EDTF\Model\ExtDateTime;
12+
use EDTF\Model\Interval;
1213
use EDTF\Model\Season;
1314
use EDTF\Model\Set;
1415

@@ -33,6 +34,13 @@ public function edtfToTimeValues( string $edtfString ): array {
3334
);
3435
}
3536

37+
if ( $edtf instanceof Interval ) {
38+
return [
39+
$this->singleValueEdtfToTimeValue( $edtf->getStartDate() ),
40+
$this->singleValueEdtfToTimeValue( $edtf->getEndDate() )
41+
];
42+
}
43+
3644
return [
3745
$this->singleValueEdtfToTimeValue( $edtf )
3846
];

tests/php/Unit/TimeValueBuilderTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,19 @@ public function testSet(): void {
102102

103103
public function testSeason(): void {
104104
$this->assertEquals(
105-
$this->newTimeValue( '+2021-01-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ),
105+
$this->newTimeValue( '+2021-01-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ), // TODO
106106
$this->edtfToTimeValue( '2021-21' )
107107
);
108108
}
109109

110+
public function testInterval(): void {
111+
$this->assertEquals(
112+
[
113+
$this->newTimeValue( '+2020-11-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH ),
114+
$this->newTimeValue( '+2021-03-00T00:00:00Z', 0, TimeValue::PRECISION_MONTH )
115+
],
116+
$this->edtfToMultipleTimeValues( '2020-11/2021-03' )
117+
);
118+
}
119+
110120
}

0 commit comments

Comments
 (0)