Checks if a time zone is valid (IANA or CLDR)

@param  string $timeZone
@return boolean
557201
protected function isValidTimeZoneId($timeZone)
    {
        return ($this->isValidIanaTimeZoneId($timeZone) !== false || $this->isValidCldrTimeZoneId($timeZone) !== false);
    }
534439
public function isPast(TimeZone $timeZone, Clock $clock = null) : bool
    {
        return $this->isBefore(LocalDateTime::now($timeZone, $clock));
    }
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;
    }
49056
public static function isValidTime($time)
    {
        if (preg_match('^(0|1|2)[0-9]([:](0|1|2|3|4|5)[0-9]){2}$', $time)) {
            $hour   = (int)substr($time, 0, 2);
            $minute = (int)substr($time, 3, 2);
            $second = (int)substr($time, 6, 2);
            if ($hour < 24 && $minute < 60 && $second < 60) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
522133
public function isValid($value)
    {
        $valueString = (string) $value;

        $this->_setValue($valueString);

        if (!preg_match('/^\d{2}:\d{2}$/', $valueString)) {
            $this->_error(self::NOT_HH_MM);
            return false;
        }

        list($hour, $minute) = sscanf($valueString, '%d:%d');
        
        if ($hour > 23 || $minute > 59) {
            $this->_error(self::INVALID);
            return false;
        }

        return true;
    }
876970
public function checkDate($value)
    {

        if ($value instanceof PointInTimeContract) {
            return $value->isValid();
        }

        if ($value instanceof DateTimeInterface) {
            return true;
        }

        // Support for legacy datetime objects like Zend_Date
        if (is_object($value) && method_exists($value, 'getTimestamp')) {
            return $this->checkInt($value->getTimestamp());
        }

        if ((!Type::isStringLike($value) && !is_numeric($value)) || strtotime($value) === false) {
            return false;
        }

        $date = date_parse($value);

        return checkdate($date['month'], $date['day'], $date['year']);
    }
487403
private function validateTimezone(DateTime $dateTime)
    {
        $dateTime = Carbon::instance($dateTime);

        // Make sure we have the proper timezone. This is to prevent a developer accidentally removing more than they
        // expect to remove
        if ($dateTime->getTimezone()->getName() !== 'UTC') {
            throw new \InvalidArgumentException('Passed datetime is not in UTC timezone.');
        }

        return $dateTime;
    }
978362
public boolean isValid(TZID tzid) {

        if (tzid == null) {
            return false;
        }

        return !Timezone.of(tzid).isInvalid(this.date, this.time);

    }
1368710
public static function defaultTimezone($timezone = null)
	{
		if ($timezone !== null)
		{
			if ( ! $timezone instanceOf DateTimeZone)
			{
				$timezone = new DateTimeZone($timezone);
			}

			static::$defaultTimezone = $timezone;
		}

		return static::$defaultTimezone;
	}
347982
public function isValid()
    {
        $now = new \DateTime('now', new \DateTimeZone('UTC'));
        $timestamp = clone $this->timestamp;

        return $timestamp->add(new \DateInterval($this->validFor)) >= $now;
    }
242971
public function validTimeStr ( $time ) {
        if ($time === '0000-00-00 00:00:00') {
            return true;
        }

        if ($this->fitNonExistingDates && $this->isNonExistingTimeString( $time )) {
            $time = $this->getPossibleDateString( $time );
        }

        return (is_string( $time ) && strlen( $time ) == 19 && $time == date( 'Y-m-d H:i:s',
                                                                              strtotime( $time ) ));
    }
402655
public function setTimezone($timezone = 'UTC')
	{
		$this->current->setTimezone(is_string($timezone) ? new \DateTimeZone($timezone) : $timezone);
		return $this;
	}
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;
        }
63349
private function validateDateTime($datetime)
    {
        if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/', $datetime, $parts) == true) {
            $time = gmmktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]);

            $input_dt = new \DateTime($datetime, new \DateTimeZone('GMT0'));
            $input_time = $input_dt->getTimestamp();
            if ($input_time === false) return false;

            return $input_time == $time;
        } else {
            return false;
        }
    }
354475
public function createRememberMe(string $timezone): bool {
		
		// set a random string
		$this->rememberMe = Utilities::getRandomString(32);
		
		if (!$this->store()) {
			return FALSE;
		}

		// serialize an array with timezone and RememberMe string
		$content = serialize([$timezone, $this->rememberMe]);
		
		// expire in 30 days
		$expire = time() + 60*60*24*30;
		
		// set cookie and return the result
		return setcookie(static::getRememberMeCookieName(), $content, $expire, '/');
		
	}
1180098
private static function isValidTimezone(string $timezone): bool
    {
        // @codeCoverageIgnoreStart
        if (self::$timezones === null) {
            self::$timezones = [];
            foreach (timezone_identifiers_list() as $zone) {
                self::$timezones[$zone] = true;
            }
        }
        // @codeCoverageIgnoreEnd

        return isset(self::$timezones[$timezone]);
    }
294436
function tzinfo($zone) {
		$ref=new DateTimeZone($zone);
		$loc=$ref->getLocation();
		$trn=$ref->getTransitions($now=time(),$now);
		$out=array(
			'offset'=>$ref->
				getOffset(new DateTime('now',new DateTimeZone('GMT')))/3600,
			'country'=>$loc['country_code'],
			'latitude'=>$loc['latitude'],
			'longitude'=>$loc['longitude'],
			'dst'=>$trn[0]['isdst']
		);
		unset($ref);
		return $out;
	}