src/DateTime/Utilities/DateTimeZoneUtil.php 1 location
|
@@ 33-44 (lines=12) @@
|
| 30 |
|
* |
| 31 |
|
* @return DateTimeZone|null |
| 32 |
|
*/ |
| 33 |
|
final public static function fromString(string $nameOrAbbreviation, DateTimeZone $default = null) |
| 34 |
|
{ |
| 35 |
|
try { |
| 36 |
|
return new DateTimeZone($nameOrAbbreviation); |
| 37 |
|
} catch (\Exception $e) { |
| 38 |
|
if (array_key_exists($nameOrAbbreviation, self::OUTLIERS)) { |
| 39 |
|
return new DateTimeZone(self::OUTLIERS[$nameOrAbbreviation]); |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
return $default; |
| 43 |
|
} |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
/** |
| 47 |
|
* Returns a DateTimeZone object based on gmt offset. |
src/Util/DateTimeZone.php 1 location
|
@@ 32-43 (lines=12) @@
|
| 29 |
|
* |
| 30 |
|
* @return \DateTimeZone |
| 31 |
|
*/ |
| 32 |
|
final public static function fromString($nameOrAbbreviation, \DateTimeZone $default = null) |
| 33 |
|
{ |
| 34 |
|
try { |
| 35 |
|
return new \DateTimeZone($nameOrAbbreviation); |
| 36 |
|
} catch (\Exception $e) { |
| 37 |
|
if (array_key_exists($nameOrAbbreviation, self::$outliers)) { |
| 38 |
|
return new \DateTimeZone(self::$outliers[$nameOrAbbreviation]); |
| 39 |
|
} |
| 40 |
|
|
| 41 |
|
return $default; |
| 42 |
|
} |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
/** |
| 46 |
|
* Returns a \DateTimeZone object based on gmt offset. |