final protected static function fromPartsXImpl()

in src/datetime/DateTime/DateTime.php [294:329]


  final protected static function fromPartsXImpl(
    Zone $timezone,
    int $year,
    int $month,
    int $day,
    int $hours,
    int $minutes,
    int $seconds,
    int $nanoseconds,
  ): this {
    using new _DateTime\ZoneOverride($timezone);
    $timestamp = Timestamp::fromRaw(
      \mktime($hours, $minutes, $seconds, $month, $day, $year),
      $nanoseconds,
    );
    $ret = new static(
      $timezone,
      $timestamp,
      $year,
      $month,
      $day,
      $hours,
      $minutes,
      $seconds,
      $nanoseconds,
    );
    // mktime() doesn't throw on invalid date/time, but silently returns a
    // timestamp that doesn't match the input; so we check for that here.
    if (
      $ret->getParts() !==
        Zoned::fromTimestamp($timezone, $timestamp)->getParts()
    ) {
      throw new Exception('Date/time is not valid in this timezone.');
    }
    return $ret;
  }