returns the offset based on timezone

@param *string $zone The timezone to calculate the offset with

@return string|int
347985
protected function calculateOffset(string $zone)
    {
        if ($this->resolveStatic(TimezoneValidation::class, 'isLocation', $zone)) {
            return $this->getOffsetFromLocation($zone);
        }

        if ($this->resolveStatic(TimezoneValidation::class, 'isUtc', $zone)) {
            return $this->getOffsetFromUtc($zone);
        }

        if ($this->resolveStatic(TimezoneValidation::class, 'isAbbr', $zone)) {
            return $this->getOffsetFromAbbr($zone);
        }

        return 0;
    }
327866
public function convertTo(string $zone, string $format = null)
    {
        $time = $this->time + $this->calculateOffset($zone);

        if (!is_null($format)) {
            return date($format, $time);
        }

        return $time;
    }
1011712
static public function timezone_name_from_abbr($offset)
    {
        // List of timezones here is not complete - https://bugs.php.net/bug.php?id=44780
        if ($tz = timezone_name_from_abbr('', $offset * 3600, 0)) {
            return $tz;
        }

        // try with more complete list (#1489261)
        $timezones = array(
            '-660' => "Pacific/Apia",
            '-600' => "Pacific/Honolulu",
            '-570' => "Pacific/Marquesas",
            '-540' => "America/Anchorage",
            '-480' => "America/Los_Angeles",
            '-420' => "America/Denver",
            '-360' => "America/Chicago",
            '-300' => "America/New_York",
            '-270' => "America/Caracas",
            '-240' => "America/Halifax",
            '-210' => "Canada/Newfoundland",
            '-180' => "America/Sao_Paulo",
             '-60' => "Atlantic/Azores",
               '0' => "Europe/London",
              '60' => "Europe/Paris",
             '120' => "Europe/Helsinki",
             '180' => "Europe/Moscow",
             '210' => "Asia/Tehran",
             '240' => "Asia/Dubai",
             '270' => "Asia/Kabul",
             '300' => "Asia/Karachi",
             '330' => "Asia/Kolkata",
             '345' => "Asia/Katmandu",
             '360' => "Asia/Yekaterinburg",
             '390' => "Asia/Rangoon",
             '420' => "Asia/Krasnoyarsk",
             '480' => "Asia/Shanghai",
             '525' => "Australia/Eucla",
             '540' => "Asia/Tokyo",
             '570' => "Australia/Adelaide",
             '600' => "Australia/Melbourne",
             '630' => "Australia/Lord_Howe",
             '660' => "Asia/Vladivostok",
             '690' => "Pacific/Norfolk",
             '720' => "Pacific/Auckland",
             '765' => "Pacific/Chatham",
             '780' => "Pacific/Enderbury",
             '840' => "Pacific/Kiritimati",
        );

        return $timezones[(string) intval($offset * 60)];
    }
1066669
def _get_tz(tz):
    
    zone = timezones.get_timezone(tz)
    if zone is None:
        zone = tz.utcoffset().total_seconds()
    return zone
778980
protected function parseSuppliedTimezone($timezone)
        {
            if ($timezone instanceof \DateTimeZone or is_null($timezone)) {
                return $timezone;
            }

            try {
                $timezone = new \DateTimeZone($timezone);
            }
            catch (Exception $error) {
                throw new \InvalidArgumentException('The supplied timezone [' . $timezone . '] is not supported.');
            }

            return $timezone;
        }
1328369
public function getUpdatedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->hasUpdatedAt()) {
            return null;
        }

        if ($timezone === null) {
            $timezone = 'UTC';
        }

        return new DateTime($this->getUpdatedAt(), new DateTimeZone($timezone));
    }
297790
public function getDeletedAtDatetime(string $timezone = null): ?DateTime
    {
        if (!$this->isDeleted()) {
            return null;
        }

        return new DateTime($this->getDeletedAt(), new DateTimeZone($timezone ?? 'UTC'));
    }
19648
public function convertTo($zone, $format = null)
    {
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string')
            //argument 1 must be a timezone identifier
            ->test(1, 'location', 'utc', 'abbr')
            //argument 2 must be a string or null
            ->test(2, 'string', 'null');

        $time = $this->time + $this->calculateOffset($zone);

        if (!is_null($format)) {
            return date($format, $time);
        }

        return $time;
    }
1169003
protected function getInternalFormatter($timezone = null)
    {
        if (!$timezone) {
            $timezone = date_default_timezone_get(); // Default to server timezone
        }

        $formatter = IntlDateFormatter::create(
            DBDate::ISO_LOCALE,
            IntlDateFormatter::MEDIUM,
            IntlDateFormatter::MEDIUM,
            $timezone
        );
        $formatter->setLenient(false);

        // Note we omit timezone from this format, and we always assume server TZ
        $formatter->setPattern(DBDatetime::ISO_DATETIME);

        return $formatter;
    }
1000367
public function matchZone($zone)
    {
        return $this->matchPart(
            $zone,
            $this->formatRegex[$this->format][self::STRZONE]
        );
    }
274224
final protected function _getTimeZone($timezone = null)
	{
		if ($timezone = strtoupper($timezone) and defined("\\DateTimeZone::{$timezone}")) {
			$timezone = new \DateTimeZone($timezone);
		} elseif (! ($timezone instanceof \DateTimeZone)) {
			@date_default_timezone_set(date_default_timezone_get());
			$timezone = new \DateTimeZone(date_default_timezone_get());
		}
		return $timezone;
	}
1276112
public static function isValidTimezone($timezone) {
		static $cache;
		if (!is_array($cache)) {
			$cache = array();
		}
		
		if (isset($cache[$timezone])) {
			return $cache[$timezone];
		}
		
		$cache[$timezone] = in_array($timezone, DateTimeZone::listIdentifiers());
		return $cache[$timezone];
	}
745840
public function toDateTime(DateTimeZone $timeZone = null): DateTime
    {
        $date = \DateTime::createFromFormat('U.u', $this->sec . '.' . $this->uSec);
        if ($timeZone) {
            $date->setTimezone($timeZone);
        }

        return $date;
    }
552540
public static function getOffset($ts = 'now', $timezone = self::UTC, $target_timezone = self::UTC) {

		if (!self::isValidTimezone($timezone) || !self::isValidTimezone($target_timezone)) {
			return 0;
		}

		$dta = new DateTime(null, new DateTimeZone($timezone));
		$dtb = new DateTime(null, new DateTimeZone($target_timezone));

		if (is_int($ts)) {
			$dta->setTimestamp($ts);
			$dtb->setTimestamp($ts);
		} else {
			$dta->modify($ts);
			$dtb->modify($ts);
		}

		return $dtb->getOffset() - $dta->getOffset();
	}
1035940
public function getCreatedAtDatetime(string $timezone = null): ?DateTime
    {
    	if ($this->created_at === null) {
    		return null;
	    }

        return new DateTime($this->created_at, new DateTimeZone($timezone ?? 'UTC'));
    }
254832
public function getTimezone()
    {
        $dateTime = new Date();
        $dateTime->setTimeZone(new DateTimeZone($this->cachetTimezone));

        return $dateTime->format('T');
    }
219276
public function UTCTimeZoneOffset() : int
    {
        $originDateTime = new \DateTime('now', $this);

        $utcTimeZone = new \DateTimeZone('UTC');
        $utcDateTime = new \DateTime('now', $utcTimeZone);

        return $utcTimeZone->getOffset($utcDateTime) - $this->getOffset($originDateTime);
    }