PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 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 / FindFromTimezoneMap.php
ameliabooking / vendor / sabre / vobject / lib / TimezoneGuesser Last commit date
FindFromOffset.php 7 months ago FindFromTimezoneIdentifier.php 7 months ago FindFromTimezoneMap.php 7 months ago GuessFromLicEntry.php 7 months ago GuessFromMsTzId.php 7 months ago TimezoneFinder.php 7 months ago TimezoneGuesser.php 7 months ago
FindFromTimezoneMap.php
79 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AmeliaVendor\Sabre\VObject\TimezoneGuesser;
6
7 use DateTimeZone;
8
9 /**
10 * Some clients add 'X-LIC-LOCATION' with the olson name.
11 */
12 class FindFromTimezoneMap implements TimezoneFinder
13 {
14 private $map = [];
15
16 private $patterns = [
17 '/^\((UTC|GMT)(\+|\-)[\d]{2}\:[\d]{2}\) (.*)/',
18 '/^\((UTC|GMT)(\+|\-)[\d]{2}\.[\d]{2}\) (.*)/',
19 ];
20
21 public function find(string $tzid, bool $failIfUncertain = false): ?DateTimeZone
22 {
23 // Next, we check if the tzid is somewhere in our tzid map.
24 if ($this->hasTzInMap($tzid)) {
25 return new DateTimeZone($this->getTzFromMap($tzid));
26 }
27
28 // Some Microsoft products prefix the offset first, so let's strip that off
29 // and see if it is our tzid map. We don't want to check for this first just
30 // in case there are overrides in our tzid map.
31 foreach ($this->patterns as $pattern) {
32 if (!preg_match($pattern, $tzid, $matches)) {
33 continue;
34 }
35 $tzidAlternate = $matches[3];
36 if ($this->hasTzInMap($tzidAlternate)) {
37 return new DateTimeZone($this->getTzFromMap($tzidAlternate));
38 }
39 }
40
41 return null;
42 }
43
44 /**
45 * This method returns an array of timezone identifiers, that are supported
46 * by DateTimeZone(), but not returned by DateTimeZone::listIdentifiers().
47 *
48 * We're not using DateTimeZone::listIdentifiers(DateTimeZone::ALL_WITH_BC) because:
49 * - It's not supported by some PHP versions as well as HHVM.
50 * - It also returns identifiers, that are invalid values for new DateTimeZone() on some PHP versions.
51 * (See timezonedata/php-bc.php and timezonedata php-workaround.php)
52 *
53 * @return array
54 */
55 private function getTzMaps()
56 {
57 if ([] === $this->map) {
58 $this->map = array_merge(
59 include __DIR__.'/../timezonedata/windowszones.php',
60 include __DIR__.'/../timezonedata/lotuszones.php',
61 include __DIR__.'/../timezonedata/exchangezones.php',
62 include __DIR__.'/../timezonedata/php-workaround.php'
63 );
64 }
65
66 return $this->map;
67 }
68
69 private function getTzFromMap(string $tzid): string
70 {
71 return $this->getTzMaps()[$tzid];
72 }
73
74 private function hasTzInMap(string $tzid): bool
75 {
76 return isset($this->getTzMaps()[$tzid]);
77 }
78 }
79