public function with(TemporalField $field, $newValue) { if ($field instanceof ChronoField) { $f = $field; switch ($f) { case ChronoField::INSTANT_SECONDS(): return $this->plus($newValue - $this->toEpochSecond(), ChronoUnit::SECONDS()); case ChronoField::OFFSET_SECONDS(): $offset = ZoneOffset::ofTotalSeconds($f->checkValidIntValue($newValue)); return $this->create($this->dateTime->toInstant($offset), $this->zone); } return $this->ofBest($this->dateTime->with($field, $newValue), $this->zone, $this->offset); } return ChronoZonedDateTimeImpl::ensureValid($this->getChronology(), $field->adjustInto($this, $newValue)); }