Jyxo\Time\Time::createTimeZone PHP Method

createTimeZone() protected method

Creates a \DateTimeZone object from a time zone definition
protected createTimeZone ( string | DateTimeZone $definition ) : DateTimeZone
$definition string | DateTimeZone Time zone definition
return DateTimeZone
    protected function createTimeZone($definition) : \DateTimeZone
    {
        if (is_string($definition)) {
            try {
                return new \DateTimeZone($definition);
            } catch (\Exception $e) {
                throw new \InvalidArgumentException(sprintf('Invalid timezone definition "%s"', $definition), 0, $e);
            }
        } elseif (!$definition instanceof \DateTimeZone) {
            throw new \InvalidArgumentException('Invalid timezone definition');
        }
        return $definition;
    }