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