PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / sabre / vobject / lib / TimezoneGuesser / FindFromTimezoneIdentifier.php
ameliabooking / vendor / sabre / vobject / lib / TimezoneGuesser Last commit date
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
FindFromTimezoneIdentifier.php
72 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Sabre\VObject\TimezoneGuesser;
6
7 use DateTimeZone;
8 use Exception;
9
10 /**
11 * Some clients add 'X-LIC-LOCATION' with the olson name.
12 */
13 class FindFromTimezoneIdentifier implements TimezoneFinder
14 {
15 public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone
16 {
17 // First we will just see if the tzid is a support timezone identifier.
18 //
19 // The only exception is if the timezone starts with (. This is to
20 // handle cases where certain microsoft products generate timezone
21 // identifiers that for instance look like:
22 //
23 // (GMT+01.00) Sarajevo/Warsaw/Zagreb
24 //
25 // Since PHP 5.5.10, the first bit will be used as the timezone and
26 // this method will return just GMT+01:00. This is wrong, because it
27 // doesn't take DST into account
28 if (!isset($tzid[0])) {
29 return null;
30 }
31 if ('(' === $tzid[0]) {
32 return null;
33 }
34 // PHP has a bug that logs PHP warnings even it shouldn't:
35 // https://bugs.php.net/bug.php?id=67881
36 //
37 // That's why we're checking if we'll be able to successfully instantiate
38 // \DateTimeZone() before doing so. Otherwise we could simply instantiate
39 // and catch the exception.
40 $tzIdentifiers = DateTimeZone::listIdentifiers();
41
42 try {
43 if (
44 (in_array($tzid, $tzIdentifiers)) ||
45 (preg_match('/^GMT(\+|-)([0-9]{4})$/', $tzid, $matches)) ||
46 (in_array($tzid, $this->getIdentifiersBC()))
47 ) {
48 return new DateTimeZone($tzid);
49 }
50 } catch (Exception $e) {
51 }
52
53 return null;
54 }
55
56 /**
57 * This method returns an array of timezone identifiers, that are supported
58 * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers().
59 *
60 * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because:
61 * - It's not supported by some PHP versions as well as HHVM.
62 * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions.
63 * (See timezonedata/php-bc.php and timezonedata php-workaround.php)
64 *
65 * @return array
66 */
67 private function getIdentifiersBC()
68 {
69 return include __DIR__.'/../timezonedata/php-bc.php';
70 }
71 }
72