|
8 | 8 | use Brick\DateTime\LocalDate; |
9 | 9 | use Brick\DateTime\LocalDateRange; |
10 | 10 | use Brick\DateTime\Parser\DateTimeParseException; |
| 11 | +use Brick\DateTime\TimeZone; |
11 | 12 |
|
12 | 13 | use function array_map; |
13 | 14 | use function iterator_count; |
@@ -240,6 +241,28 @@ public function providerToNativeDatePeriod(): array |
240 | 241 | ]; |
241 | 242 | } |
242 | 243 |
|
| 244 | + /** |
| 245 | + * @dataProvider providerToInterval |
| 246 | + */ |
| 247 | + public function testToInterval(string $range, string $timeZone, string $expectedInterval): void |
| 248 | + { |
| 249 | + $actualResult = LocalDateRange::parse($range)->toInterval(TimeZone::parse($timeZone)); |
| 250 | + self::assertSame($expectedInterval, (string) $actualResult); |
| 251 | + } |
| 252 | + |
| 253 | + public function providerToInterval(): array |
| 254 | + { |
| 255 | + return [ |
| 256 | + ['2010-01-01/2010-01-01', 'UTC', '2010-01-01T00:00Z/2010-01-02T00:00Z'], |
| 257 | + ['2010-01-01/2020-12-31', 'UTC', '2010-01-01T00:00Z/2021-01-01T00:00Z'], |
| 258 | + ['2022-03-20/2022-03-26', 'Europe/London', '2022-03-20T00:00Z/2022-03-27T00:00Z'], |
| 259 | + ['2022-03-20/2022-03-27', 'Europe/London', '2022-03-20T00:00Z/2022-03-27T23:00Z'], |
| 260 | + ['2022-03-20/2022-03-26', 'Europe/Berlin', '2022-03-19T23:00Z/2022-03-26T23:00Z'], |
| 261 | + ['2022-03-20/2022-03-27', 'Europe/Berlin', '2022-03-19T23:00Z/2022-03-27T22:00Z'], |
| 262 | + ['2022-01-01/2022-12-31', 'Europe/Berlin', '2021-12-31T23:00Z/2022-12-31T23:00Z'], |
| 263 | + ]; |
| 264 | + } |
| 265 | + |
243 | 266 | /** |
244 | 267 | * @dataProvider providerIntersectsWith |
245 | 268 | */ |
|
0 commit comments