blob: f340a396231b5e29bb453423e501fe17de95b618 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
declare(strict_types=1);
namespace Sabre\VObject\TimezoneGuesser;
use DateTimeZone;
use Sabre\VObject\Component\VTimeZone;
use Sabre\VObject\TimeZoneUtil;
/**
* Some clients add 'X-LIC-LOCATION' with the olson name.
*/
class GuessFromLicEntry implements TimezoneGuesser
{
public function guess(VTimeZone $vtimezone, bool $failIfUncertain = false): ?DateTimeZone
{
if (!isset($vtimezone->{'X-LIC-LOCATION'})) {
return null;
}
$lic = (string) $vtimezone->{'X-LIC-LOCATION'};
// Libical generators may specify strings like
// "SystemV/EST5EDT". For those we must remove the
// SystemV part.
if ('SystemV/' === substr($lic, 0, 8)) {
$lic = substr($lic, 8);
}
return TimeZoneUtil::getTimeZone($lic, null, $failIfUncertain);
}
}
|