Create a CarbonTimeZone from mixed input.

@param DateTimeZone|string|int|null $object     original value to get CarbonTimeZone from it.
@param DateTimeZone|string|int|null $objectDump dump of the object for error messages.

@return false|static
487553
public static function instance($object = null, $objectDump = null)
    {
        $tz = $object;

        if ($tz instanceof static) {
            return $tz;
        }

        if ($tz === null) {
            return new static();
        }

        if (!$tz instanceof DateTimeZone) {
            $tz = static::getDateTimeZoneFromName($object);
        }

        if ($tz === false) {
            if (Carbon::isStrictModeEnabled()) {
                throw new InvalidArgumentException('Unknown or bad timezone ('.($objectDump ?: $object).')');
            }

            return false;
        }

        return new static($tz->getName());
    }
1205436
public static function factory($time = null, $timezone = null) {
        $timezone = static::timezone($timezone);

        if ($time instanceof DateTime) {
            return $time->setTimezone($timezone);
        }

        if (is_numeric($time)) {
            $time = '@' . $time;
        }

        $dt = new DateTime($time);
        $dt->setTimezone($timezone);

        return $dt;
    }
655075
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
	{
		if ($object === null) {
			$object = new FieldOptions();
		}

		if ($end === null) {
			$end = strlen($input);
		}

		while ($start < $end) {
			$tag = Binary::decodeVarint($input, $start);
			$wireType = $tag & 0x7;
			$number = $tag >> 3;
			switch ($number) {
				case 1:
					if ($wireType !== 0) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number);
					}
					$object->ctype = Binary::decodeVarint($input, $start);
					break;
				case 2:
					if ($wireType !== 0) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number);
					}
					$object->packed = (bool)Binary::decodeVarint($input, $start);
					break;
				case 6:
					if ($wireType !== 0) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number);
					}
					$object->jstype = Binary::decodeVarint($input, $start);
					break;
				case 5:
					if ($wireType !== 0) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number);
					}
					$object->lazy = (bool)Binary::decodeVarint($input, $start);
					break;
				case 3:
					if ($wireType !== 0) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number);
					}
					$object->deprecated = (bool)Binary::decodeVarint($input, $start);
					break;
				case 10:
					if ($wireType !== 0) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number);
					}
					$object->weak = (bool)Binary::decodeVarint($input, $start);
					break;
				case 999:
					if ($wireType !== 2) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
					}
					if (!(isset($object->uninterpretedOption) && is_array($object->uninterpretedOption))) {
						$object->uninterpretedOption = array();
					}
					$length = Binary::decodeVarint($input, $start);
					$expectedStart = $start + $length;
					if ($expectedStart > $end) {
						throw new ProtobufException('Not enough data.');
					}
					$object->uninterpretedOption[] = UninterpretedOptionMeta::fromProtobuf($input, null, $start, $start + $length);
					if ($start !== $expectedStart) {
						throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
					}
					break;
				default:
					switch ($wireType) {
						case 0:
							Binary::decodeVarint($input, $start);
							break;
						case 1:
							$start += 8;
							break;
						case 2:
							$start += Binary::decodeVarint($input, $start);
							break;
						case 5:
							$start += 4;
							break;
						default:
							throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
					}
			}
		}

		return $object;
	}
612428
public function setDateFromDateTime(DateTime $date = NULL, DateTimeZone $dateTimeZone = NULL) {
    $dateTimeZone = !empty($dateTimeZone) ? $dateTimeZone : new DateTimeZone('UTC');
    $this->date = !empty($date) ? $date : new DateTime($date);
    $this->date->setTimezone($dateTimeZone);
  }
401616
static ObjectMapper createModifiableObjectMapper(final ObjectMapper objectMapper) {
        objectMapper.registerModule(new BuilderModule());
        registerModule(objectMapper, "com.fasterxml.jackson.datatype.guava.GuavaModule");
        registerModule(objectMapper, "com.fasterxml.jackson.datatype.jdk8.Jdk8Module");
        registerModule(objectMapper, "com.fasterxml.jackson.datatype.joda.JodaModule");
        registerModule(objectMapper, "com.fasterxml.jackson.datatype.jsr310.JavaTimeModule");
        registerAdditionalModules(objectMapper, System::getProperty);
        objectMapper.configure(DeserializationFeature.FAIL_ON_TRAILING_TOKENS, true);
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        objectMapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, false);
        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        objectMapper.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false);
        objectMapper.setDateFormat(new StdDateFormat());
        return objectMapper;
    }
734663
public static function createFromDefaultFormat($datetime, $timezone = null)
    {
        return self::createFromFormat(self::$defaultFormat, $datetime, $timezone);
    }
692419
public static function createFromFormat($format, $time, $object = NULL)
    {
        $date = $object ? \DateTime::createFromFormat($format, $time, $object)
            : \DateTime::createFromFormat($format, $time);

        return $date !== false ?
            new self($date->format('Y-m-d H:i:s'), $date->getTimezone())
            : false;
    }
185904
public static function fromTimestamp($timestamp, DateTimeZone $dateTimeZone = null)
    {
        $base = new GregorianDateTime(
            date('Y-m-d H:i:s', $timestamp),
            self::checkForDateTimeZone($dateTimeZone)
        );

        return new DateTime($base);
    }
776326
private DateTime zonedDateTimeToJodaTime(final ChronoZonedDateTime<?> date) {
        return date == null ? null : new DateTime(date.toInstant().toEpochMilli(), DateTimeZone.UTC);
    }
1104462
public function toDateTime(\DateTimeZone $timeZone = null): \DateTime
    {
        if (null === self::$utc) {
            self::$utc = new \DateTimeZone('UTC');
        }

        $date = \DateTime::createFromFormat('!Y-m-d', $this->getValue(), $timeZone ?: self::$utc);
        if (!$date instanceof \DateTime) {
            $date = \DateTime::createFromFormat('!Y-m-d', (new \DateTime())->format('Y-m-d'), $timeZone ?: self::$utc);
        }

        if ($date->getOffset() !== 0) {
            $date->setTimezone(self::$utc);
        }

        return $date;
    }
1075623
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
	{
		if ($object === null) {
			$object = new FileDescriptorSet();
		}

		if ($end === null) {
			$end = strlen($input);
		}

		while ($start < $end) {
			$tag = Binary::decodeVarint($input, $start);
			$wireType = $tag & 0x7;
			$number = $tag >> 3;
			switch ($number) {
				case 1:
					if ($wireType !== 2) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
					}
					if (!(isset($object->file) && is_array($object->file))) {
						$object->file = array();
					}
					$length = Binary::decodeVarint($input, $start);
					$expectedStart = $start + $length;
					if ($expectedStart > $end) {
						throw new ProtobufException('Not enough data.');
					}
					$object->file[] = FileDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length);
					if ($start !== $expectedStart) {
						throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
					}
					break;
				default:
					switch ($wireType) {
						case 0:
							Binary::decodeVarint($input, $start);
							break;
						case 1:
							$start += 8;
							break;
						case 2:
							$start += Binary::decodeVarint($input, $start);
							break;
						case 5:
							$start += 4;
							break;
						default:
							throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
					}
			}
		}

		return $object;
	}
1190342
protected static function safeCreateDateTimeZone($object)
        {
            if ($object instanceof DateTimeZone) {
                return $object;
            }

            $tz = @timezone_open((string) $object);

            if ($tz === false) {
                throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')');
            }

            return $tz;
        }
894402
public function create(Container $object)
    {
        $sql = "INSERT INTO %1\$s (%2\$s) VALUES (%3\$s)";
        $placeholders = [];
        $values = [];
        foreach ($this->fields as $field) {
            if (property_exists($object, $field)
                && !isset($this->annotations['properties'][$field]['From'])
                && isset($object->$field)
            ) {
                $placeholders[$field] = '?';
                $values[] = $object->$field;
            }
        }
        $this->flattenValues($values);
        $sql = sprintf(
            $sql,
            $this->identifier,
            implode(', ', array_keys($placeholders)),
            implode(', ', $placeholders)
        );
        $stmt = $this->getStatement($sql);
        try {
            $retval = $stmt->execute($values);
        } catch (PDOException $e) {
            return false;
        }
        if (count($this->primaryKey) == 1) {
            $pk = $this->primaryKey[0];
            try {
                $object->$pk = $this->adapter->lastInsertId($this->identifier);
                $this->load($object);
            } catch (PDOException $e) {
                // Means this is not supported by this engine.
            }
        }
        return $retval;
    }
195930
public static function fromDateTime(\DateTimeInterface $dateTime) : ZonedDateTime
    {
        $localDateTime = LocalDateTime::fromDateTime($dateTime);

        $dateTimeZone = $dateTime->getTimezone();

        if ($dateTimeZone === false) {
            throw new DateTimeException('This DateTime object has no timezone.');
        }

        $timeZone = TimeZone::fromDateTimeZone($dateTimeZone);

        if ($timeZone instanceof TimeZoneOffset) {
            $timeZoneOffset = $timeZone;
        } else {
            $timeZoneOffset = TimeZoneOffset::ofTotalSeconds($dateTime->getOffset());
        }

        $instant = Instant::of($dateTime->getTimestamp(), $localDateTime->getNano());

        return new ZonedDateTime($localDateTime, $timeZoneOffset, $timeZone, $instant);
    }
691370
public static function createDateFromDateTime(DateTime $dateTime, DateTimeZone $dateTimeZone = NULL) {
    $openYLocaleDate = new OpenYLocaleDate();
    $openYLocaleDate->setDateFromDateTime($dateTime, $dateTimeZone);
    return $openYLocaleDate;
  }
800690
public static function createAdapterObject($object)
    {
        $wrapperObject = self::create($object, null, function ($method, $arguments, $result) {
            $data['method']    = $method;
            $data['arguments'] = $arguments;

            $appType = php_sapi_name();
            if ($appType == 'cli') {
                $processName = @cli_get_process_title();
                if (strpos($processName, 'msf') !== false) {
                    $appType = 'msf';
                }
            } else {
                $appType = 'web';
            }

            if ($appType != 'msf' && $result instanceof \Generator) {
                $data['result'] = $result->getReturn();
                return $data;
            }

            $data['result'] = $result;
            return $data;
        });

        return $wrapperObject;
    }
1229376
function _createFormat() {
    $objectname                   = null;
    switch( $this->format ) {
      case 'xcal':
        $objectname               = ( isset( $this->timezonetype )) ?
                                 strtolower( $this->timezonetype )  :  strtolower( $this->objName );
        $this->componentStart1    = $this->elementStart1 = '<';
        $this->componentStart2    = $this->elementStart2 = '>';
        $this->componentEnd1      = $this->elementEnd1   = '</';
        $this->componentEnd2      = $this->elementEnd2   = '>'.$this->nl;
        $this->intAttrDelimiter   = '<!-- -->';
        $this->attributeDelimiter = $this->nl;
        $this->valueInit          = null;
        break;
      default:
        $objectname               = ( isset( $this->timezonetype )) ?
                                 strtoupper( $this->timezonetype )  :  strtoupper( $this->objName );
        $this->componentStart1    = 'BEGIN:';
        $this->componentStart2    = null;
        $this->componentEnd1      = 'END:';
        $this->componentEnd2      = $this->nl;
        $this->elementStart1      = null;
        $this->elementStart2      = null;
        $this->elementEnd1        = null;
        $this->elementEnd2        = $this->nl;
        $this->intAttrDelimiter   = '<!-- -->';
        $this->attributeDelimiter = ';';
        $this->valueInit          = ':';
        break;
    }
    return $objectname;
  }