Skip to content

Commit

Permalink
Merge pull request #619 from sash04ek/patch-3
Browse files Browse the repository at this point in the history
fixed issue: Undefined index: plusminus #467
  • Loading branch information
phil-davis committed Nov 9, 2023
2 parents 9341286 + e4d7c4e commit c832cc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/DateTimeParser.php
Expand Up @@ -93,7 +93,7 @@ public static function parseDuration(string $duration): \DateInterval

$invert = false;

if ('-' === $matches['plusminus']) {
if (isset($matches['plusminus']) && '-' === $matches['plusminus']) {
$invert = true;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/VObject/DateTimeParserTest.php
Expand Up @@ -34,6 +34,12 @@ public function testParseICalendarDurationDateInterval(): void
self::assertEquals($expected, DateTimeParser::parseDuration('-PT3M'));
}

public function testParseDurationZero(): void
{
$expected = new \DateInterval('PT0S');
self::assertEquals($expected, DateTimeParser::parseDuration('P'));
}

public function testParseICalendarDurationFail(): void
{
$this->expectException(InvalidDataException::class);
Expand Down

0 comments on commit c832cc3

Please sign in to comment.