Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty TZID #375

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/TimeZoneUtil.php
Expand Up @@ -135,7 +135,7 @@ public static function getTimeZone($tzid, Component $vcalendar = null, $failIfUn
// Since PHP 5.5.10, the first bit will be used as the timezone and
// this method will return just GMT+01:00. This is wrong, because it
// doesn't take DST into account.
if ('(' !== $tzid[0]) {
if (!empty($tzid) && '(' !== $tzid[0]) {
// PHP has a bug that logs PHP warnings even it shouldn't:
// https://bugs.php.net/bug.php?id=67881
//
Expand Down
22 changes: 22 additions & 0 deletions tests/VObject/Component/VTimeZoneTest.php
Expand Up @@ -51,4 +51,26 @@ public function testGetTimeZone()
$obj->VTIMEZONE->getTimeZone()
);
}

public function testEmptyTimeZone()
{
$input = <<<HI
BEGIN:VCALENDAR
VERSION:2.0
PRODID:YoYo
BEGIN:VTIMEZONE
TZID:
END:VTIMEZONE
END:VCALENDAR
HI;

$obj = Reader::read($input);

$tz = new \DateTimeZone(date_default_timezone_get());

$this->assertEquals(
$tz,
$obj->VTIMEZONE->getTimeZone()
);
}
}